Open this example in the interactive library
Source code
import csv
rows = csv.DictReader(['name,score', 'Ada'], restval='pending')
print(next(rows))Sample output
{'name': 'Ada', 'score': 'pending'}
Use fallback values for missing CSV columns in Python.
Open this example in the interactive library
import csv
rows = csv.DictReader(['name,score', 'Ada'], restval='pending')
print(next(rows)){'name': 'Ada', 'score': 'pending'}