-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
Description
There could be an option for fwrite and fread to dump/read the unclassed representation of objects. In such a case whole IO process can be much faster, because we don't have to format POSIXct, [I]Date and other classes for writing to file, we just unclass them, and write numbers (or any other base type they use) to a file. Later when reading with fread we provide colClasses (or yaml), and those numbers (or another base types) are properly recognized as their original class.
library(data.table)
dt = data.table(a=as.Date("2015-01-01"), b=as.POSIXct("2015-01-01 15:30:20"))
fwrite(dt, "fwrite-tests.csv", AsIs=TRUE)
system("cat fwrite-tests.csv")
#a, b
#16436, 1420106420
fread("fwrite-tests.csv", colClasses = c(a="Date", b="POSIXct"))
# a b
# <Date> <POSc>
#1: 2015-01-01 2015-01-01 15:30:20dselivanov, zachmayer and MichaelChirico