0

I am trying to download a zip file from the google patent bulk data website http://storage.googleapis.com/patents/grantbib/2014/ipgb20140107_wk01.zip, unzip the file and read the table. I used this procedure Using R to download zipped data file, extract, and import data

setwd("/var/folders/gk/n1wfrbqx6ss4x3vz7qp9lf3c0000gn/T//RtmpG7LUSs")
temp <- tempfile() 
download.file("http://storage.googleapis.com/patents/grantbib/2014/ipgb20140107_wk01.zip",temp)
data <- read.table(unz(temp, "ipgb20140107_wk01.dat"))
unlink(temp)

and I tried to set the working directory to the same place as the temporary file similar to what is suggested in here Getting error in file(file, "rt"): cannot open the connection but I still get the same error message:

    Error in open.connection(file, "rt") : cannot open the connection
In addition: Warning message:
In open.connection(file, "rt") :
  cannot locate file 'ipgb20140107_wk01.dat' in zip file '/var/folders/gk/n1wfrbqx6ss4x3vz7qp9lf3c0000gn/T//RtmpG7LUSs/file476796049c7'
Amleto
  • 584
  • 1
  • 7
  • 25
  • What does your `temp` file say? mine says `"C:\\Users\\NAME\\AppData\\Local\\Temp\\Rtmpeu2ZbY\\file3e6c5162b84"` with the double `\\`. – user113156 Oct 19 '18 at 10:15
  • @user113156 mine says "/var/folders/gk/n1wfrbqx6ss4x3vz7qp9lf3c0000gn/T//RtmpG7LUSs/file476796049c7" – Amleto Oct 19 '18 at 10:47
  • There error is cause by the fact that there is no ".dat" file in the zip folder. There is a "txt" and "xml" file but not dat file. – Dave2e Oct 19 '18 at 11:57
  • #Dave2e is right: Use the following; `temp <- tempfile() download.file("http://storage.googleapis.com/patents/grantbib/2014/ipgb20140107_wk01.zip",temp) data <- read.delim(unz(temp, "ipgb20140107lst.txt")) unlink(temp)` – user113156 Oct 19 '18 at 15:45

0 Answers0