Skip to content

csv.QUOTE_MINIMAL does not quote lines with escaped quote character. #105116

Open
@theGOTOguy

Description

@theGOTOguy

The documented behavior of csv.QUOTE_MINIMAL is that fields containing the quote character should be quoted.

However, running:

import csv

with open('trash.csv', 'w') as csvfile:
  writer = csv.writer(csvfile, quoting=csv.QUOTE_MINIMAL, doublequote=False, escapechar='\\')
  writer.writerow(['"'])
> cat trash.csv
\"

My expectation is that this field would have been quoted (e.g., "\""), as it contains the quote character (escaped). If this is intended behavior, then the documentation should be clarified, or if it's not, this is a bug.

Your environment

  • Operating system and architecture: Ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions