-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
fread from data.table 1.9.4 doesn't remove whitespace at the beginning of the fields.
Here is the example of the file content:
id, time, obsType, comment
90, 2014-01-03 03:43:31.0138, "l2", "69D88XZ M7ADF H1RSV4"
91, 2014-01-05 13:51:54.2273, "m3", "NULL"
Let's say, it is read by standard read.csv function
data1 <- read.csv("./file.dat", header=TRUE, colClasses=c("integer", "POSIXct", "factor", "character"))
Then names of the columns will be displayed correctly:
names(data1)
[1] "id" "time" "obsType" "comment"
But when exactly the same data is read by fread it doesn't remove beginning spaces from the heading and data:
data2 <- fread(input="./sample_data.csv",header=TRUE, colClasses=c("integer", "POSIXct", "factor", "character"))
names(data2)
[1] "id" " time" " obsType" " comment"
data[1,2]
"2014-01-03 03:43:31 EET"
unlist(data2[1,2,with=FALSE])
time
" 2014-01-05 13:51:54.2273"