csv.DictReader()
csv.DictReader() is a Python function in the CSV Module category. Returns a reader that maps each row to a dict with field names as keys. The syntax is csv.DictReader(csvfile, fieldnames=None, **fmtparams). Returns: DictReader iterator. A typical example: with open("data.csv") as f:
for row in csv.DictReader(f):
print(row["Name"]) # Access by column name. A close sibling is csv.reader(), which returns a reader object that iterates over lines in a CSV file. A close sibling is csv.writer(), which returns a writer object for writing rows to a CSV file. A close sibling is csv.DictWriter(), which returns a writer that maps dicts to CSV rows using fieldnames. A close sibling is csv.writer.writerow(), which writes a single row to the CSV file (row is a sequence of values). More about this category: CSV file reading and writing — reader, writer, DictReader, DictWriter. For a broader walkthrough, read the CSV Module guide.