Csv
The `csv` module implements classes for reading and writing tabular data in comma-separated values format. It handles the complexities of quoting, escaping, and dialect variations. The guide walks through Reading CSV, Writing CSV, DictReader & DictWriter, Custom Dialects, Handling Headers. `csv.reader(file, delimiter=",")` returns an iterator of row lists. Each row is split by the delimiter. Use `next(reader)` to skip the header row. The `quoting` parameter controls how quoted fields are handled. `csv.writer(file)` creates a writer. `writer.writerow(["a", "b", "c"])` writes a single row. `writer.writerows(rows)` writes multiple rows. The `lineterminator="\n"` parameter controls line endings across platforms. `csv.DictReader(file)` maps each row to an `OrderedDict` using the header row as keys. `csv.DictWriter(file, fieldnames)` writes dictionaries. Use `writeheader()` to write the header row from `fieldnames`. The guide is organized into 5 sections that build on each other, each pairing a prose explanation with runnable code. Browse the individual functions covered by this guide in the CSV Module category.