Expand description
csv.writer / csv.DictWriter the way CPython writes them.
Default dialect: , delimiter, " quote doubled on escape,
QUOTE_MINIMAL, \r\n line terminator. A field is quoted when it
contains the delimiter, the quote character, \r or \n. A row that is
a single empty field is written as "" so it is not an empty line.
Values are rendered with Python str() semantics via cell:
None → empty, True/False, ints plain, floats by repr.
Functions§
- cell
- Python
str()of a JSON scalar as csv would stringify it. - needs_
quotes 🔒 - read_
dicts csv.DictReader: the first row names the columns. A short row leaves its missing columns absent (Python’sNone); a long row’s extras are dropped; a blank line is skipped.- read_
rows csv.readeron a file opened withnewline="": the C state machine from_csv.c, default dialect. Quoted fields may span lines and keep their line endings verbatim; a quote inside an unquoted field is literal; a doubled quote inside a quoted field is one quote. A blank line yields an empty row.- write_
dicts DictWriter(fieldnames=cols): header, then each row’s values in column order. A missing key writes an empty cell (restval=""); extra keys are ignored (extrasaction="ignore").- write_
row - Write one row.
fieldsare already stringified.