Python Forum
Csv writer meaning of quoting - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Csv writer meaning of quoting (/thread-38349.html)



Csv writer meaning of quoting - mg24 - Oct-01-2022

Hi Team,

in below code I want understand what quoting does.

What is the meaning of these, in which situation others to use it.

csv.QUOTE_NONNUMERIC
csv.QUOTE_ALL
csv.QUOTE_MINIMAL

with open(fullpath, "w", newline="") as outfile:
        writer = csv.writer(outfile, delimiter="|", quoting=csv.QUOTE_NONNUMERIC)



RE: Csv writer meaning of quoting - ibreeden - Oct-01-2022

From the manual:
Quote:csv.QUOTE_ALL

Instructs writer objects to quote all fields.

csv.QUOTE_MINIMAL

Instructs writer objects to only quote those fields which contain special characters such as delimiter, quotechar or any of the characters in lineterminator.

csv.QUOTE_NONNUMERIC

Instructs writer objects to quote all non-numeric fields.

Instructs the reader to convert all non-quoted fields to type float.

csv.QUOTE_NONE

Instructs writer objects to never quote fields. When the current delimiter occurs in output data it is preceded by the current escapechar character. If escapechar is not set, the writer will raise Error if any characters that require escaping are encountered.

Instructs reader to perform no special processing of quote characters.



RE: Csv writer meaning of quoting - Gribouillis - Oct-01-2022

This pymotw3 issue explains a lot too.