newbie question(file-delete trailing comma)

Robin Becker robin at reportlab.com
Mon Feb 26 05:51:14 EST 2007


kavitha thankaian wrote:
> hi,
>    
>   i have a file which has the contents as follows:
>    
>   a,b,c,d,
>   a1,b1,c1,d1,
>   a2,b2,c2,d2,
>    
>   i would like to delete all the trailing commas,,
>    
>   if someoneknows pls help me,,
>    
>   kavitha
......

I often use sed for such small problems.

c:\tmp>cat ex.txt
a,b,c,d,
a1,b1,c1,d1,
a2,b2,c2,d2,

c:\tmp>sed -e"s/,$//" ex.txt
a,b,c,d
a1,b1,c1,d1
a2,b2,c2,d2

c:\tmp>

that doesn't involve python of course. I recommend one of the many tutorial 
introductions to python if the problem requires its use.
-- 
Robin Becker




More information about the Python-list mailing list