Keith Wiley
Keith Wiley

Reputation: 31

Problem with R downloading zipped ACS data files

I have been having a problem trying to download a zipped file with American Community Survey (ACS) data. The file is a zipped folder that contains zipped sub-folders within it. I want to download and unzip the file leaving the individual zipped sub-folders. The code I am using is:

ACS.url<-"https://www2.census.gov/programs-surveys/acs/summary_file/2019/data/5_year_entire_sf/Tracts_Block_Groups_Only.zip"

dir<-getwd()

zip.file<-"CTrctACS19.zip"

zip.combine<-as.character(paste(dir,zip.file,sep="/"))

download.file(ACS.url,destfile=zip.combine,mode="wb")

unzip(zip.file) 

After running the code I get what appears to be a correct download, but the unzip does not work. I get the following error message:

 In unzip(zip.file) : error 1 in extracting from zip file

The downloaded file is only about half of the size zip of the file I am trying to download (the original is 3.7G at Census website but I have about 1.8G) so I think it is not downloading the data correctly. I tried to access the downloaded file with the winzip program and it would not work either. I can download files from that website if they are smaller and don't include zipped subfolders. Any help would be appreciated.

Upvotes: 1

Views: 115

Answers (0)

Related Questions