Objective
Create a Python program that converts data in CSV format to JSON.
Instructions
- Read an integer
n, then a header linename,ageand thenndata rows. - Read the rows with
csv.DictReader, passing it the list made of the header and the rows. - Convert the age of each row into an integer.
- Show the list of dictionaries converted to JSON with
json.dumps(list, ensure_ascii=False).
2
name,age
Ana,30
Luis,25
[{"name": "Ana", "age": 30}, {"name": "Luis", "age": 25}]
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise