Courses/Data Formats & Networking

๐ŸŒ Data Formats & Networking

CSV Files

Read and write tabular data with the csv module.

csv.reader yields each row as a list; csv.DictReader gives dicts keyed by the header row.

import csv, io

text = "name,score\nAda,92\nLinus,87"
reader = csv.DictReader(io.StringIO(text))
for row in reader:
    print(row["name"], row["score"])
main.py
Output
Press Run to execute.
Expected output
58

Sign in to track your progress across lessons.