I am downloading hundreds of files which have a format:
{
"result": [
{
"Lines": "130",
"Lon": 21.0566243,
"VehicleNumber": "1000",
"Time": "2020-12-22 18:55:03",
"Lat": 52.1812215,
"Brigade": "1"
},
{
"Lines": "311",
"Lon": 21.0817553,
"VehicleNumber": "1001",
"Time": "2020-12-22 18:54:52",
"Lat": 52.2407755,
"Brigade": "2"
}
]
}
My desired output is a list of dictionaries
[
{
"Lines": "130",
"Lon": 21.0566243,
"VehicleNumber": "1000",
"Time": "2020-12-22 18:55:03",
"Lat": 52.1812215,
"Brigade": "1"
},
{
"Lines": "311",
"Lon": 21.0817553,
"VehicleNumber": "1001",
"Time": "2020-12-22 18:54:52",
"Lat": 52.2407755,
"Brigade": "2"
}
]
combined from all the files.
What is a proper way to handle it?
I tried downloading with
def download(file_name):
with open(os.path.join(path_to_data,file_name), 'a') as outfile:
json.dump(response.json(), outfile)
But then I got one file with a couple of dictionaries with {"result":} and can't even load it as a json. Should I save each json in a separate file instead of making it just one file? If so, should i make a list of names for function download?