I'm trying to parse some data as follows:
subject_data
{"72744387":{"retired":null,"Filename":"2021-07-18 23-16-26 frontlow.jpg"}}
{"72744485":{"retired":null,"Filename":"2021-07-21 07-39-57 frontlow.jpg"}}
{"72744339":{"retired":null,"Filename":"2021-07-17 04-55-03 frontlow.jpg"}}
I'd like to get the file name from all of this data, but I'd like to do so without using that first number, as these numbers are randomized and there are a lot. So far I have:
classifications['subject_data_json'] = [json.loads(q) for q in classifications.subject_data]
data = classifications['subject_data_json']
print(data[3])
This prints {'72744471': {'retired': None, 'Filename': '2021-07-21 04-11-45 frontlow.jpg'}}
But I'd like to print just the Filename for each of the data sets. print(data[3]['Filename'])
fails, and I'm not sure how to get the information without using the number.
CodePudding user response:
I'd go with a nested expression
print([v['Filename'] for i in data for k, v in i.items()])