Open this example in the interactive library
Source code
import csv
from io import StringIO
text = StringIO('name,score'+chr(10)+'Ada,90'+chr(10)+'Ben,80')
print(list(csv.DictReader(text)))Sample output
[{'name': 'Ada', 'score': '90'}, {'name': 'Ben', 'score': '80'}]