I have a problem with fread() reading a column of directory paths using "\" as the directory separator. The issue is that the trailing directory separator throws an error in fread().
For the below example csv file,
file,size
"windows\user",123
both fread() and read.csv() agree and both convert the \ to \\
> fread("example.csv")
file size
1: windows\\user 123
However, for the following example fread() gives an error while read.csv() is fine.
file,size
"windows\user\",123
read.csv() gives
> read.csv("example.csv")
file size
1 windows\\user\\ 123
While the fread() error looks like this
> fread("example.csv",verbose=TRUE)
Input contains no \n. Taking this to be a filename to open
File opened, filesize is 0.000 GB
File is opened and mapped ok
Detected eol as \r\n (CRLF) in that order, the Windows standard.
Using line 2 to detect sep (the last non blank line in the first 'autostart') ... sep=','
Found 2 columns
First row with 2 fields occurs on line 1 (either column names or first row of data)
All the fields on line 1 are character fields. Treating as the column names.
Count of eol after first data row: 2
Subtracted 1 for last eol and any trailing empty lines, leaving 1 data rows
Error in fread("example.csv", verbose = TRUE) :
' ends field 1 on line 1 when detecting types: "windows\user\",123
I would really like to avoid doing
DT = data.table(read.csv("example.csv"))
if at all possible.