1
votes

OS: Win 7 64 bit RStudio Version 1.1.463

As per Getting and Cleaning Data course, I attempted to download a csv file with method = curl:

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

Error in download.file(fileUrl, destfile = "./cameras.csv", method = "curl") : 'curl' call had nonzero exit status

However, method = libcurl resulted a successful download:

download.file(fileUrl, destfile = "./cameras.csv", method = "libcurl")

trying URL 'https://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD' downloaded 9443 bytes

changing from *http***s** to http produced exactly the same results for curl and libcurl, respectively.

Is there anyway to make this download work via method = curl as per the course?

Thanks

2

2 Answers

1
votes

As you can see from ?download.file:

For methods "wget" and "curl" a system call is made to the tool given by method, and the respective program must be installed on your system and be in the search path for executables. They will block all other activity on the R process until they complete: this may make a GUI unresponsive.

Therefore, you should install curlfirst. See this How do I install and use curl on Windows? to learn how. Best!

1
votes

I believe there were a few issues here: Followed the steps in the link quoted by @JonnyCrunch

a) Reinstalled Git for windows;

b) added C:\Program Files\Git\mingw64\bin\ to the 'PATH' variable;

c) Disabled Use Internet Explorer library/proxy for HTTP in RStudio in: Tools > Options > Packages

d) Attempted steps in 'e)' below and added data.baltimorecity.gov website to exclusions as per Kaspersky anti-virus' prompt;

e) Then in RStudio:

options(download.file.method = "curl")

download.file(fileUrl, destfile="./data/cameras.csv")

Success!

Thank you