4

I'm trying to download the Chicago Crime stats data (CSV format) from their government website. This is the link for download:

https://data.cityofchicago.org/api/views/ijzp-q8t2/rows.csv?accessType=DOWNLOAD

but it only works when you copy it to the browser and hit enter.

I am wondering how to download the csv file on terminal? Can I use:

curl -O https://data.cityofchicago.org/api/views/ijzp-q8t2/rows.csv?accessType=DOWNLOAD > Chicago.csv

I want to save the Chicago.csv to my current work directory on ssh.

5
  • Have you tried the curl command you suggested? If so, did you get any errors? Commented Oct 18, 2013 at 15:53
  • 1
    btw, you're above works... but it took AGEEES to get going... Commented Oct 18, 2013 at 15:54
  • 2
    Use either -O localfilename or > localfilename, not both. Commented Oct 18, 2013 at 15:57
  • yes, I tried my own way, but because the file is so big. I don't know whether it works until the download finishes. I didn't see any errors when I do curl -O data.cityofchicago.org/api/views/ijzp-q8t2/… > Chicago.csv Commented Oct 18, 2013 at 16:00
  • 2
    use either curl -o outputfile.csv http://path/to/file or curl http://path/to/file > outputfile.csv. -o <file> Writes output to <file> instead of stdout, -O Writes output to a local file named like the remote file we get. Commented Oct 18, 2013 at 16:19

2 Answers 2

8

Your command works, however it take a long time to "compute" the file, which is huge (5360469 rows, and after 215 MB downloaded, I only got 881705 rows, so the final file size should be about 1.3GB).

If you try with another set (let's say "Flu Shot Clinic Locations - 2012", 1058 rows, 192kB) you can see that your command works perfectly, even if it does not write to Chicago.csv.

Take a look at man page:

-o, --output <file>
          Write  output to <file> instead of stdout.
-O, --remote-name
          Write output to a local file named like the remote file we get. (Only the file part of the remote file is used, the path is cut off.)

When you use the following command:

curl -O https://data.cityofchicago.org/api/views/ijzp-q8t2/rows.csv?accessType=DOWNLOAD > Chicago.csv

The data is written to rows.csv?accessType=DOWNLOAD, stdout remains empty, so Chicago.csv file will remain empty.

Instead, you should use either:

curl -o Chicago.csv https://data.cityofchicago.org/api/views/ijzp-q8t2/rows.csv?accessType=DOWNLOAD

Or:

curl https://data.cityofchicago.org/api/views/ijzp-q8t2/rows.csv?accessType=DOWNLOAD > Chicago.csv
Sign up to request clarification or add additional context in comments.

Comments

3

have you tried wget? like this:

wget --no-check-certificate --progress=dot https://data.cityofchicago.org/api/views/ijzp-q8t2/rows.csv?accessType=DOWNLOAD

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.