the input file what i have is already opened with write mode.
say i have a file input.txt which has
a,b,c,d,
and i need the output also in the same input.txt,,ie., the trailing comma in
the input.txt file should be deleted,,,i dont need a file output.txt,,,
is there a way??
kavitha
Mohammad Tayseer <[EMAIL PROTECTED]> wrote:
ok, it should be
----------
import sys
in_file = open(sys.argv[1])
out_file = open(sys.argv[2], 'w')
for line in in_file:
print >> out_file, line.strip().strip(',')
----------
strip(',') will remove the ',' char from the beginning & end of the string, not
the middle. empty strip() will remove whitespaces from the beginning & end of
the string
I hope this solves your problem
kavitha thankaian <[EMAIL PROTECTED]> wrote: hi
i would like to have the output as follows:
a,b,c,d
a1,b1,c1,d1
a2,b2,c2,d2
i would like to delete only the comma at the end and not the commas inbetween.
thanks,,,
---------------------------------
Any questions? Get answers on any topic at Yahoo! Answers. Try it now.
---------------------------------
Heres a new way to find what you're looking for - Yahoo! Answers --
http://mail.python.org/mailman/listinfo/python-list