Using the CSV module

Stefan Sonnenberg-Carstens stefan.sonnenberg at pythonmeister.com
Wed May 9 05:40:13 EDT 2007


Most of the time I found the CSV module not as useful as it might be -
due to the restrictions you describe.

Why not write a simple parser class ?

On Mi, 9.05.2007, 10:40, Nathan Harmston wrote:
> Hi,
>
> I ve been playing with the CSV module for parsing a few files. A row
> in a file looks like this:
>
> some_id\t|\tsome_data\t|t\some_more_data\t|\tlast_data\t\n
>
> so the lineterminator is \t\n and the delimiter is \t|\t, however when
> I subclass Dialect and try to set delimiter is "\t|\t" it says
> delimiter can only be a character.
>
> I know its an easy fix to just do .strip("\t") on the output I get,
> but I was wondering
> a) if theres a better way of doing this when the file is actually
> being parsed by the csv module
> b) Why are delimiters only allowed to be one character in length.
>
> Many Thanks in advance
> Nathan
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>




More information about the Python-list mailing list