How to directly perform write.csv in R into tar.gz format?

本秂侑毒 提交于 2019-11-27 02:13:03

问题


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.


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!