regex will do it
import re line = re.sub(r"\s+", "\t", line) print line Vince On Tue, Jun 2, 2009 at 11:42 AM, jyotsna guleria <jyotsna.gule...@gmail.com>wrote: > > Hello every one, > > I am trying to parse a file: > > I want to convert all the spaces in between the characters to single tab. > > e.g: my file has contents like: > > 1G5 79011 1 0 2 0 0 0 > 0 0 0 0 > 5Ht-2 60459 1 1 0 0 0 0 > 0 0 0 0 > > > I want them to be separated by a single tab not with spaces.. > > It should look like: > > 1G5 79011 1 0 2 0 0 0 0 0 0 0 > 5Ht-2 60459 1 1 0 0 0 0 0 0 0 0 > > each separated by Tab... > > It is a text file containing such a data .. > > > Thanks > -- > Jyotsna Guleria > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor