I have a big data.frame that I want to write into a compressed CSV file. Is there any way to directly write the data into a CSV.TAR.GZ compressed file instead of performing write.csv/gzip steps in order to reduce DISK access?
Thanks.
Use gzfile
(or bzfile
for bzip2 archiving, or xzfile
for xz archiving).
z <- gzfile("mtcars.csv.gz")
write.csv(mtcars, z)
PS. If you only have one data frame, surely you don't need tar.
来源:https://stackoverflow.com/questions/17492409/how-to-directly-perform-write-csv-in-r-into-tar-gz-format