Reputation: 1288
I am trying to download and unzip a file from the internet using the following code. I have a PC running on Windows 10.
#################### Set Working Directory #################
setwd("C:/Users/Sharif/OneDrive/Data/FEC Data/Committee Information")
#################### Download File ############
download.file("https://www.fec.gov/data/browse-data/?tab=bulk-data/files/bulk-downloads/1980/indiv80.zip", destfile = "1980 - Committee Information.zip")
unzip("1980 - Committee Information.zip") ## Does not work and produces an error
For some reason, I get the following error when I run the unzip function and the file does not unzip into my working directory.
Warning message:
In unzip("1980 - Committee Information.zip") :
error 1 in extracting from zip file
Any help you could offer would be greatly appreciated. Thank You!
Upvotes: 3
Views: 3187
Reputation: 3791
This works on my machine.
download.file("https://www.fec.gov/files/bulk-downloads/1980/indiv80.zip", destfile = "1980_Committee_Information.zip")
unzip("1980_Committee_Information.zip")
For some reason, the url
you are requesting is not downloading the file. Looking into the page source (View-source
from your browser) reveals the actual url
used by the website to serve a request.
Upvotes: 2