Re: Problem in splitting a string
From: Jeff Shannon (jeff_at_ccvcorp.com)
Date: 07/22/04
- Next message: Mike Stenzler: "any cx_Oracle sample code?"
- Previous message: Jeff Epler: "Re: a newbie OptParse thread. Is there a way to catch all?"
- In reply to: Angelo Secchi: "Problem in splitting a string"
- Next in thread: Paul McGuire: "Re: Problem in splitting a string"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 22 Jul 2004 12:11:04 -0700
Angelo Secchi wrote:
>Hi,
>I have string of numbers and words like
>
>',,,,,,23,,,asd,,,,,"name,surname",,,,,,,\n'
>
>and I would like to split (I'm using string.split()) it using comma as
>separator but I do not want to split in two also the "name,surname"
>field. In other word I would like python in separating fields to skip
>that particular comma.
>
>
You may be able to use regular expressions (the re module) to hack
something together that'll work for your particular case. In the
general case, though, splitting delimiter-separated values in the
presence of quoting and escaping is a nontrivial problem.
I remember some discussion, quite a while ago, about several people
working on a DSV module that would handle all of this stuff, but I don't
know what became of that.
Jeff Shannon
Technician/Programmer
Credit International
- Next message: Mike Stenzler: "any cx_Oracle sample code?"
- Previous message: Jeff Epler: "Re: a newbie OptParse thread. Is there a way to catch all?"
- In reply to: Angelo Secchi: "Problem in splitting a string"
- Next in thread: Paul McGuire: "Re: Problem in splitting a string"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|