On 2016-03-11 20:49, Fillmore wrote:
On 3/11/2016 2:41 PM, Fillmore wrote:
Is there some directive I can give CVS reader to tell it to stop
screwing with my text?

OK, I think I reproduced my problem at the REPL:

  >>> import csv
  >>> s = '"Please preserve my doublequotes"\ttext1\ttext2'
  >>> reader = csv.reader([s], delimiter='\t')
  >>> for row in reader:
...     print(row[0])
...
Please preserve my doublequotes
  >>>

:(

How do I instruct the reader to preserve my doublequotes?

As an aside. split() performs the job correctly...

  >>> allVals = s.split("\t")
  >>> print(allVals[0])
"Please preserve my doublequotes"
  >>>

>>> import csv
>>> s = '"Please preserve my doublequotes"\ttext1\ttext2'
>>> reader = csv.reader([s], delimiter='\t', quotechar=None)
>>> for row in reader:
...     print(row[0])
...
"Please preserve my doublequotes"
>>>

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to