R Reading in a zip data file without unzipping it

后端 未结 7 2250
青春惊慌失措
青春惊慌失措 2020-12-04 15:22

I have a very large zip file and i am trying to read it into R without unzipping it like so:

temp <- tempfile(\"Sales\", fileext=c(\"zip\"))
data <- re         


        
7条回答
  •  无人及你
    2020-12-04 15:36

    The gzfile function along with read_csv and read.table can read compressed files.

    library(readr)
    df = read_csv(gzfile("file.csv.gz"))
    
    library(data.table)
    df = read.table(gzfile("file.csv.gz"))
    

    read_csv from the readr package can read compressed files even without using gzfile function.

    library(readr)  
    df = read_csv("file.csv.gz")
    

    read_csv is recommended because it is faster than read.table

提交回复
热议问题