R: readBin workaround to character limit (10 000 bytes)?



I have a file that consists both of a XML character header and binary data, which is then read using readBin in R:



zz <- file('myfile', 'rb')

# Read header
x <- readBin(zz, 'character')

# Read binary data
...


However, when the header exceeds 10 000 bytes, I get the following:



Warning message:
In readBin(zz, 'character') :
null terminator not found: breaking string at 10000 bytes


I have tried to loop until the string match the end of the header and then concatenate the strings together, but then the XML does not validate as some of the parts has corrupted endings (e.g. \xa0W\x97^\xff\177 is added in the end).


How should I deal with the readBin character limit - are there any simple workarounds?


Any kinds of suggestions are appreciated. Thanks!


No comments:

Post a Comment