user3706202
user3706202

Reputation: 215

Download.file function does not seem to work

I want to extract some data for a .csv online into R. So therefore Im doing this (Ive already created a dir called "data")

fileUrl <- "https://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD"
download.file(fileUrl, destfile = "./data/cameras.csv", method="curl")

It gives the my following error however:

 Warning messages:
 1: running command 'curl  "https://data.baltimorecity.gov/api/views/dz54-     2aru/rows.csv?accessType=DOWNLOAD"  -o "./data/cameras.csv"' had status    127 
 2: In download.file(fileUrl, destfile = "./data/cameras.csv", method  = "curl") download had nonzero exit status

And if I remove the method= "curl" I get

Error in download.file(fileUrl, destfile = "./data/cameras.csv") : 
unsupported URL scheme

Any thoughts on what goes wrong?

Upvotes: 1

Views: 1528

Answers (2)

Beclyn
Beclyn

Reputation: 11

I also had this problem. Changing method = "curl" to method = "auto" worked for me.

Upvotes: 1

Muhammad
Muhammad

Reputation: 1

Note the http instead of https, the code below will work:

fileUrl <- "http://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD"
download.file(fileUrl, destfile = "./data/cameras.csv",method="curl")

Upvotes: 0

Related Questions