replacing multiple instances of commas beginning at specific position

striker striker at trip.net
Mon Nov 14 12:43:57 EST 2005


I have a comma delimited text file that has multiple instances of
multiple commas.  Each file will contain approximatley 300 lines.  For
example:

one, two, three,,,,four,five,,,,six
one, two, three,four,,,,,,,,,,eighteen,   and so on.

There is one time when multiple commas are allowed.  Just prior to the
letters ADMNSRC there should be one instance of 4 commas. (
,eight,,,,ADMNSRC,thirteen, ).  The text ADMNSRC is NOT in the same
place on each line.

What would be the best approach to replace all instances of multiple
commas with just one comma, except for the 4 commas prior to ADMNSRC?

Any help would be greatly appreciated.
TIA,
Kevin




More information about the Python-list mailing list