Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue7350] csv doesn't handle escaped characters properly

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Nov 18, 2009, 11:11 AM

Post #1 of 3 (148 views)
Permalink
[issue7350] csv doesn't handle escaped characters properly

New submission from Eric Torstenson <e_torstenson [at] hotmail>:

When I use CSV with a separator, if there is an escaped separator in the
field, it causes the next field to become part of the current one:

file = csv.reader(open(filename), delimiter='\t', quotechar="'")
for words in file:
print words[0-8]

If, say line 3 contains: '1709' 'PF01322' 'Cytochrom_C_2'
'Cytochrome_C_2; ' 'Cytochrome C\'' 'Finn RD, Bateman A' 'anon' 'Sarah
Teichmann'

Column 4 will be printed as:
Cytochrome C\'\tFinn RD, Bateman A'

I've checked this with a spreadsheet application, and it opened this
line just fine, but when I used csv to parse, I had to remove that
escaped single quote to get my columns to work out properly for that line.

----------
components: Extension Modules
messages: 95441
nosy: est_python_tracker
severity: normal
status: open
title: csv doesn't handle escaped characters properly
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7350>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 20, 2009, 6:37 AM

Post #2 of 3 (129 views)
Permalink
[issue7350] csv doesn't handle escaped characters properly [In reply to]

Virgil Dupras <hsoft [at] hardcoded> added the comment:

You have to tell the reader how to handle escaping. In your case, you
should send escapechar="\\" in reader()'s kwargs.

----------
nosy: +vdupras

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7350>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Nov 20, 2009, 1:52 PM

Post #3 of 3 (122 views)
Permalink
[issue7350] csv doesn't handle escaped characters properly [In reply to]

Changes by Terry J. Reedy <tjreedy [at] udel>:


----------
resolution: -> invalid
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7350>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.