Re: Splitting a string with extra parameters

2006-04-06 Thread Fulvio
Alle 11:23, giovedì 06 aprile 2006, Chris P ha scritto:
 when splitting based on a delimiter of , the above string gets broken up
 in 5 columns instead of 4 due to the , in the money amount.

There should be cvs package in the python directory. Why don't you try that 
way?
Reading some help gives more details of its use.

F
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Splitting a string with extra parameters

2006-04-06 Thread Amit Khemka
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).

for details and more options see python-docs.

cheers,
amit.

On 4/6/06, Fulvio [EMAIL PROTECTED] wrote:
 Alle 11:23, giovedì 06 aprile 2006, Chris P ha scritto:
  when splitting based on a delimiter of , the above string gets broken up
  in 5 columns instead of 4 due to the , in the money amount.

 There should be cvs package in the python directory. Why don't you try that
 way?
 Reading some help gives more details of its use.

 F
 --
 http://mail.python.org/mailman/listinfo/python-list



--

Amit Khemka -- onyomo.com
Home Page: www.cse.iitd.ernet.in/~csd00377
Endless the world's turn, endless the sun's Spinning, Endless the quest;
I turn again, back to my own beginning, And here, find rest.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Splitting a string with extra parameters

2006-04-06 Thread Andrew Gwozdziewycz

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
[EMAIL PROTECTED]
http://ihadagreatview.org
http://and.rovir.us


-- 
http://mail.python.org/mailman/listinfo/python-list