CSV
A plain-text format for tabular data: one row per line, values separated by commas.
CSV (comma-separated values) is the lingua franca of spreadsheets and data exports. Each line is a row; commas separate the columns. Python’s built-in csv module reads and writes it safely — handling quoting and commas inside fields — and csv.DictReader gives each row as a dictionary keyed by column name.
import csv, io
text = "name,age\nAda,36\nBo,29\n"
rows = list(csv.DictReader(io.StringIO(text)))
print(rows[0]["name"], rows[0]["age"])
print(len(rows), "rows")
Output
Ada 36 2 rows
Where this shows up in real Python
CSV is where data work often starts: exports from spreadsheets, reports, and simple datasets you clean or summarise.
Commonly used CSV tools
csv.reader(f)— read rows as listscsv.DictReader(f)— read rows as dicts by headercsv.writer(f)— write rowscsv.DictWriter(f, fieldnames)— write dicts as rowsnewline=''— open CSV files with this to avoid blank lines
Official documentation: Python Library Reference: csv