On Fri, Jan 9, 2009 at 3:26 PM, Leland <lelandp...@gmail.com> wrote: > Hi, > > I have some formatted strings that I'd like to split and get the > meaningful data, here is the example of the string format. The big > difference of these two line are the second double quote set at the > second line > 100-01001-001,"Diode,Small Signal,SOT-23",1,D46, > 100-01004-001,"Diode,High Voltage General Purpose,600mA,200V,SOT-23", > 3,"D24,D72,D104", > > I want to split the string into the following format: > '100-01001-001', 'Diode,Small Signal,SOT-23', '1', 'D46' > '100-01004-001', 'Diode,High Voltage General Purpose,600mA, > 200V,SOT-23', '3', 'D24,D72,D104' > [snip code]
This looks like a CSV file to me. If that is the case, it is easier to use the built-in csv module than to try to write your own parser. http://docs.python.org/library/csv.html#module-csv
-- http://mail.python.org/mailman/listinfo/python-list