issue with csv module (subject module name spelling correction, too)
Martin A. Brown
martin at linux-ip.net
Fri Mar 11 16:20:44 EST 2016
More information about the Python-list mailing list
Fri Mar 11 16:20:44 EST 2016
- Previous message (by thread): issue with CVS module
- Next message (by thread): issue with CVS module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Good afternoon Fillmore, >>>> import csv >>>> s = '"Please preserve my doublequotes"\ttext1\ttext2' >>>> reader = csv.reader([s], delimiter='\t') > How do I instruct the reader to preserve my doublequotes? Change the quoting used by the dialect on the csv reader instance: reader = csv.reader([s], delimiter='\t', quoting=csv.QUOTE_NONE) You can use the same technique for the writer. If you cannot create your particular (required) variant of csv by tuning the available parameters in the csv module's dialect control, I'd be a touch surprised, but, it is possible that your other csv readers and writers are more finicky. Did you see the parameters that are available to you for tuning how the csv module turns your csv data into records? https://docs.python.org/3/library/csv.html#dialects-and-formatting-parameters Judging from your example, you definitely want to use quoting=csv.QUOTE_NONE, because you don't want the module to do much more than split('\t'). Good luck, -Martin -- Martin A. Brown http://linux-ip.net/
- Previous message (by thread): issue with CVS module
- Next message (by thread): issue with CVS module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list