The following
$.ajax({
url: "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv",
success: function(csv) {
const output = Papa.parse(csv, {
header: true, // Convert rows to Objects using headers as properties
});
if (output.data) {
console.log(output.data);
} else {
console.log(output.errors);
}
},
error: function(jqXHR, textStatus, errorThrow){
console.log(textStatus);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.1.0/papaparse.min.js"></script>
Gives
[
{
"Province/State": "Anhui",
"Country/Region": "Mainland China",
"Lat": "31.8257",
"Long": "117.2264",
"1/22/20": "1",
"1/23/20": "9",
"1/24/20": "15",
"1/25/20": "39",
"1/26/20": "60",
"1/27/20": "70",
"1/28/20": "106",
"1/29/20": "152",
"1/30/20": "200",
"1/31/20": "237",
"2/1/20": "297",
"2/2/20": "340",
"2/3/20": "408",
"2/4/20": "480",
"2/5/20": "530"
},
{
"Province/State": "Beijing",
"Country/Region": "Mainland China",
"Lat": "40.1824",
"Long": "116.4142",
"1/22/20": "14",
"1/23/20": "22",
"1/24/20": "36",
"1/25/20": "41",
"1/26/20": "68",
"1/27/20": "80",
"1/28/20": "91",
But the dates are single objects that I need and the number next to it too, so I'd need something like
{
"Province/State": "Beijing",
"Country/Region": "Mainland China",
"Lat": "40.1824",
"Long": "116.4142",
"cases": [
{
"date": "1/28/20",
"people": "91",
],
"date": "1/29/20",
"people": "99",
],
"date": "1/30/20",
"people": "101",
],
},
Literally I'm looking for a properly formatted json with single objects