gh-155097: Add converter and formatter parameters in csv.reader and csv.writer - #155099
gh-155097: Add converter and formatter parameters in csv.reader and csv.writer#155099serhiy-storchaka wants to merge 4 commits into
Conversation
… and csv.writer They are used instead of float() and str() for converting between fields and values. Both take the 0-based position of the field in the row as the first argument, so the conversion can depend on the column. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Documentation build overview
128 files changed ·
|
|
Could you please look at this @smontanaro? |
|
@serhiy-storchaka It looks fine to me. I would add the little bit of motivation you mentioned above to the descriptions of the converter and formatter arguments:
And in your original issue:
I personally don't see an example where this would be useful to me. Maybe an example would be useful (I guess your |
|
Thank you. Add the bit of motivation (why index is here) and examples. Rationale for the order of arguments is for reviewers, not end users. Users will just accept it. And yes, the wrappers around the |
The converter parameter of
csv.readeris used instead offloat()for converting unquoted fields, and the formatter parameter ofcsv.writeris used instead ofstr()for converting values to strings. Both are called with the 0-based position of the field in the row as the first argument, so the conversion can depend on the column.