Dev Helpers
← Back

Read CSV records

Read CSV records. A self-contained example using the Python standard library.

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'}]