Stripping occasional carriage returns with fread.data.table?

447 views Asked by At

I am using the fread() function from data.table package and dealing with messy input files. Some of the lines have an additional carriage return at the end. Is it possible to make it ignore ^M?

I can preprocess it some other way but it would best if I can handle it directly with fread...

It's currently giving me this error:

Error in fread(s$file, sep = "\t", nrows = 1, skip = 0, header = FALSE) : 
Line ending is \r\r\n. R's download.file() appears to add the extra \r in 
text mode on Windows. Please download again in binary mode (mode='wb') 
which might be faster too. Alternatively, pass the URL directly to 
fread and it will download the file in binary mode for you. 
0

There are 0 answers