how can i change the text delimiter

Fredrik Lundh fredrik at pythonware.com
Wed Aug 30 06:24:26 EDT 2006


"sonald" wrote:

> Thanks for a quick response...
> E.g record is: "askin"em"

that's usually stored as "askin""em" in a CSV file, and the csv module
has no problem handling that:

    >>> import csv, StringIO
    >>> source = StringIO.StringIO('"askin""em"\n')
    >>> list(csv.reader(source))
    [['askin"em']]

to use another quote character, use the quotechar option to the reader
function:

>>> source = StringIO.StringIO('|askin"em|\n')
>>> list(csv.reader(source, quotechar='|'))
[['askin"em']]

> Also please note that the string cannot be modified at all.

not even by the Python program that reads the data?  sounds scary.

what's fastcsv, btw?  the only thing google finds with that name is a
Ruby library...

</F> 






More information about the Python-list mailing list