split problem if the delimiter is inside the text limiter

Tino Wildenhain tino at wildenhain.de
Wed Mar 18 13:11:36 CET 2009


rewonka wrote:
> Hi,
> 
> I had a problem, i would like to process a file into a PSQL, but in
> the file the delimiter char is ':'
> and i have the same charater inside the text field also.
> something like this:
> text = 1:23:34:"sample: text":" something"
> if I use text.split(':')
> it will be ['1', '23', '34', '"sample', 'text"', 'something']
> but it's not good for me, because the delimiter is in text limiter  "
> "
> 
> is it a solution, that is fast to process ? so i don't need to split
> by "hand made" function

You should check out the csv module, you can define quote char and
delimiter and this should just work.

Regards
Tino
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3241 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20090318/85af0424/attachment.bin>


More information about the Python-list mailing list