Splitting a string with extra parameters
Andrew Gwozdziewycz
apgwoz at gmail.com
Thu Apr 6 08:00:08 EDT 2006
On Apr 6, 2006, at 7:38 AM, Amit Khemka wrote:
> I guess you should use "re" module ... In this case re.split("\D,\D",
> YOUR_STRING) should work. (splits only when "," is between two
> non-digits).
This works assuming all line elements are quoted.
This would fail if (and this too my knowledge is proper CSV):
"Col 1 data 2,000", Col 2 data 3000, "Col 3 data 4,000"
Since the second element doesn't have a comma, it doesn't have to be
quoted.
It's probably best to use the built in CSV parser assuming your data
conforms to
the basic rules of CSV files.
---
Andrew Gwozdziewycz
apgwoz at gmail.com
http://ihadagreatview.org
http://and.rovir.us
More information about the Python-list
mailing list