Reputation: 73
I have a zipped file named master.zip
which contains 2 CSV files inside it: file1.csv
and file2.csv
I want to read file1.csv
only, something like: read_csv('master/file1.csv')
, but without having to unzip master.zip
. How can I achieve this with R?
Upvotes: 6
Views: 8763
Reputation: 6768
You just need to use the native function unz()
. Let's assume that master.zip
is in your working directory,
# just a list of files inside master.zip
master <- as.character(unzip("master.zip", list = TRUE)$Name)
# load the first file "file1.csv"
data <- read.csv(unz("master.zip", "file1.csv"), header = TRUE,
sep = ",")
Upvotes: 11