Python Forum
Csv writer meaning of quoting
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Csv writer meaning of quoting
#1
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)
Reply
#2
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.
Reply
#3
This pymotw3 issue explains a lot too.
rob101 likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to understand the meaning of the line of code. jahuja73 0 313 Jan-23-2024, 05:09 AM
Last Post: jahuja73
  [split] NameError: name 'csvwriter' is not defined. Did you mean: 'writer'? cathy12 4 3,352 Sep-01-2022, 07:41 PM
Last Post: deanhystad
Sad pandas writer create "corrupted" file freko75 1 2,831 Jun-14-2022, 09:57 PM
Last Post: snippsat
  meaning of -> syntax in function definition DrakeSoft 5 1,977 Apr-09-2022, 07:45 AM
Last Post: DrakeSoft
  CSV writer - no output?? Clives 6 2,578 Mar-30-2022, 04:09 PM
Last Post: Clives
  Operator meaning explanation Sherine 3 2,053 Jul-31-2021, 11:05 AM
Last Post: Sherine
  parser.parse_args() meaning vinci 2 2,625 Oct-26-2020, 04:13 PM
Last Post: vinci
  What is the meaning of k in this function? giladal 3 2,738 Aug-15-2020, 12:32 PM
Last Post: buran
  Closing Files - CSV Reader/Writer lummers 2 2,619 May-28-2020, 06:36 AM
Last Post: Knight18
  Here what is the meaning of span=(1,2) ,match='1'? srisrinu 1 2,124 Apr-27-2020, 10:22 AM
Last Post: anbu23

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020