I am trying to read a zip file that has 1 csv file in it.
It works great when I know the csv file name but when I just try to extract the zip file alone, it doesn't work.
Here is an example of where it does works:
zip_file <- abc.zip
csv_file <- abcde.csv
data <- read.table(unz(zip_file,csv_file), skip = 10, header=T, quote="\"", sep=",")
Here is where it doesn't work when I try to only extract the zip file:
read.table(zip_file, skip = 10, nrows=10, header=T, quote="\"", sep=",")
An error comes up saying:
Error in read.table(attachment_file, skip = 10, nrows = 10, header = T, :
no lines available in input
In addition: Warning messages:
1: In readLines(file, skip) : line 2 appears to contain an embedded nul
2: In readLines(file, skip) : line 3 appears to contain an embedded nul
3: In readLines(file, skip) :
incomplete final line found on
'C:\Users\nickk\AppData\Local\Temp\RtmpIrqdl8\file2c9860d62381'
So this shows there is definitely a csv file present because it works when I include the csv file name but when I just do the zip file, then the error comes up.
For context, the reason why I do not want to include the csv file name is because I need to read this zip file daily and the name of the csv file changes with no pattern everytime. So my goal is to only read the zip file to bypass this.
Thanks!