2

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. 
smci
  • 32,567
  • 20
  • 113
  • 146
fatdragon
  • 2,211
  • 4
  • 26
  • 43
  • 1
    What format is `s$file`? Please provide at least a sample of the file where you can replicate the issue! – Arun Jun 11 '15 at 11:12
  • Here's a sample http://download.bls.gov/pub/time.series/lu/lu.periodicity – fatdragon Jun 11 '15 at 16:22
  • 2
    Possible duplicate of [fread(): reading table with \r\r\n as newline symbol](http://stackoverflow.com/questions/33339656/fread-reading-table-with-r-r-n-as-newline-symbol) – smci Aug 10 '16 at 23:22

0 Answers0