I've got this URL (https://opendata.ecdc.europa.eu/covid19/casedistribution/json/) and want to convert the URL in a CSV-File. So I got the latest data and doesn't need to update the data manually in the CSV-File. It is possible?
-
Does this answer your question? [How to get JSON from webpage into Python script](https://stackoverflow.com/questions/12965203/how-to-get-json-from-webpage-into-python-script) – user120242 Jul 14 '20 at 18:15
-
Does this answer your question? [How can I convert JSON to CSV?](https://stackoverflow.com/questions/1871524/how-can-i-convert-json-to-csv) – user120242 Jul 14 '20 at 18:18
-
What don't you know how to do, get the JSON data from the URL, or convert it into a CSV file? Also, what does "…and doesn't need to update the data manually in the CSV-File" mean. – martineau Jul 14 '20 at 18:28
3 Answers
@TheBeas1 you can go two ways:
1). You can write your own script to parse data from this URL, which is basically JSON data into csv. You can use csv and json library to achieve that in python.
2). You can use any existing converter of JSON to CSV, for example: https://www.convertcsv.com/json-to-csv.htm

- 113
- 2
- 2
- 11
If you are looking for a NO CODE solution, I want to add to the previous answer and point out the new API for convertcsv.com at -> https://www.ConvertCSV.IO -- (same team as convertcsv.com runs it so you know it works.) Using the API requires a token (you get one for free when you sign up) and signup can be done with google/github oauth or any email address.
I just signed up, tested the solution and it works quickly and on the first try in curl. Here is the curl command I used (you will need to use your own API key from the site).
C:\Users>curl -X POST "https://www.convertcsv.io/api/v1/json2csv" -F infile=https://opendata.ecdc.europa.eu/covid19/casedistribution/json/ -H "Authorization: Token 89808d4a5a0de3bae2f6221b9336e4e3d345234" -o c:\Users\Desktop\TESTDATA.csv

- 11
- 1
Use the pandas' library's built-in read_json
and to_csv
.
After downloading the file,
import pandas as pd
df = pd.read_json('covid19.json')
df.to_csv('covid19_json_as_csv.csv')