[Tutor] How o convert spaces into tabs??

" शंतनू (Shantanoo)" shantanoo at gmail.com
Tue Jun 2 20:15:47 CEST 2009



jyotsna guleria 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 ..
>
You can try re module.
More info at:
http://docs.python.org/library/re.html
http://www.regular-expressions.info/python.html

-- 


More information about the Tutor mailing list