Re: issue with CVS module

2016-03-12 Thread alister
On Fri, 11 Mar 2016 16:26:02 -0500, Fillmore wrote: > On 3/11/2016 4:15 PM, Mark Lawrence wrote: >> >> https://docs.python.org/3/library/csv.html#csv.Dialect.doublequote >> >> > thanks, but my TSV is not using any particular dialect as far as I > understand... > > Thank you, anyway Every variati

Re: issue with CVS module

2016-03-11 Thread Fillmore
On 3/11/2016 2:41 PM, Fillmore wrote: I have a TSV file containing a few strings like this (double quotes are part of the string): A big thank you to everyone who helped with this and with other questions. My porting of one of my Perl scripts to Python is over now that the two scripts produ

Re: issue with CVS module

2016-03-11 Thread Fillmore
On 3/11/2016 4:15 PM, Mark Lawrence wrote: https://docs.python.org/3/library/csv.html#csv.Dialect.doublequote thanks, but my TSV is not using any particular dialect as far as I understand... Thank you, anyway -- https://mail.python.org/mailman/listinfo/python-list

Re: issue with CVS module

2016-03-11 Thread Fillmore
On 3/11/2016 4:14 PM, MRAB wrote: >>> 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" >>> This worked! thank you MRAB --

Re: issue with CVS module

2016-03-11 Thread Mark Lawrence
On 11/03/2016 19:41, Fillmore wrote: I have a TSV file containing a few strings like this (double quotes are part of the string): '"pragma: CacheHandler=08616B7E907744E026C9F044250EA55844CCFD52"' After Python and the CVS module has read the file and re-printed the value, the string has become:

Re: issue with CVS module

2016-03-11 Thread MRAB
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' >>

Re: issue with CVS module

2016-03-11 Thread Ben Finney
Fillmore writes: > Possibly, but I am having a hard time letting it know that it should > leave each and every char alone You're using the wrong module, then. To use the ‘csv’ module is to have the sequence of characters parsed to extract component values, which cannot also “leave each and every

Re: issue with CVS module

2016-03-11 Thread mm0fmf
On 11/03/2016 20:32, Fillmore wrote: myReader = csv.reader(csvfile, delimiter='\t',quotechar='') From reading that the quotechar is null. You have a single quote and single quote with nothing in the middle. Try this: myReader = csv.reader(csvfile, delimiter='\t',quotechar="'") i.e doublequ

Re: issue with CVS module

2016-03-11 Thread Fillmore
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') >

Re: issue with CVS module

2016-03-11 Thread Fillmore
On 3/11/2016 3:05 PM, Joel Goldstick wrote: Enter the python shell. Import csv then type help(csv) It is highly configurable Possibly, but I am having a hard time letting it know that it should leave each and every char alone, ignore quoting and just handle strings as strings. I tried pl

Re: issue with CVS module

2016-03-11 Thread Joel Goldstick
On Fri, Mar 11, 2016 at 2:41 PM, Fillmore wrote: > > I have a TSV file containing a few strings like this (double quotes are > part of the string): > > '"pragma: CacheHandler=08616B7E907744E026C9F044250EA55844CCFD52"' > > After Python and the CVS module has read the file and re-printed the > valu

issue with CVS module

2016-03-11 Thread Fillmore
I have a TSV file containing a few strings like this (double quotes are part of the string): '"pragma: CacheHandler=08616B7E907744E026C9F044250EA55844CCFD52"' After Python and the CVS module has read the file and re-printed the value, the string has become: 'pragma: CacheHandler=08616B7E90