0 votes
1 view
in R Programming by (5.3k points)

"Lots of online csv's are zipped. Is there a way to download, unzip the archive, and load the data to a data.frame using R? #Rstats"

I was also trying to do this today, but ended up just downloading the zip file manually.

I tried something like:

fileName <- "http://www.newcl.org/data/zipfiles/a1.zip"

con1 <- unz(fileName, filename="a1.dat", open = "r")

but I feel as if I'm a long way off. Any thoughts?

1 Answer

0 votes
by (25.3k points)

To download, extract, and import a zipped data file in R, you can do the following:

Create a temporary file to store the file to be downloaded:

temp <- tempfile()

Download the file from the url:

download.file("file url",temp)

To extract the file from temp file and read the data using read.table:

data <- read.table(unz(temp, "file1.dat"))

Remove the temporary file:


Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !