1

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

LocoGris
  • 3,991
  • 3
  • 13
  • 30
analytics-josh
  • 115
  • 1
  • 11

2 Answers2

1

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!

LocoGris
  • 3,991
  • 3
  • 13
  • 30
1

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

analytics-josh
  • 115
  • 1
  • 11
  • Why are you going to all this trouble? The point of having different download options is so that if one doesn't work, you can try another. Since `method="libcurl"` worked, your problem is solved right there – Hong Ooi Mar 05 '19 at 08:33
  • Tried to get 'curl' method to work as per the specs in the course and get to the bottom of root causes. Jumping from one method to another, using 'http', as opposed to 'https' like in other similar posts, does not solve the actual problem. – analytics-josh Mar 05 '19 at 08:35
  • "Jumping from one method to another" _solved the actual problem_ of downloading the file. – Hong Ooi Mar 05 '19 at 08:37
  • "Jumping from one method to another" did not solve the issue of following course's instructions and did not get "curl" method to work in my environment. there would not have been "curl" method, or any other any other download method, had it not offered its own advantages of using it, right? – analytics-josh Mar 05 '19 at 09:53