Re: newbie question(file-delete trailing comma)

2007-03-01 Thread kavitha thankaian
thanks,,, i tried another way and it works,,, f.writelines(','.join([('\"%s\"' % some[field]) for field in field_order])) thanks a lot,,, Gabriel Genellina <[EMAIL PROTECTED]> wrote: En Wed, 28 Feb 2007 08:34:29 -0300, kavitha thankaian escribió: > thanks,, > now i have on

Re: newbie question(file-delete trailing comma)

2007-02-28 Thread Gabriel Genellina
En Wed, 28 Feb 2007 08:34:29 -0300, kavitha thankaian <[EMAIL PROTECTED]> escribió: > thanks,, > now i have one more problem,,, > the strings should be seperated in an order,,, > some={1:'a', 2:7, 3:'c', 4:'d'} > i need the output to be a,c,d,7 > before my code was: > field_or

Re: newbie question(file-delete trailing comma)

2007-02-28 Thread kavitha thankaian
thanks,, now i have one more problem,,, the strings should be seperated in an order,,, some={1:'a', 2:7, 3:'c', 4:'d'} i need the output to be a,c,d,7 before my code was: field_order = [1,3,4,2] for field in field_order: f.writelines('\"%s\",' % someprt[f

Re: newbie question(file-delete trailing comma)

2007-02-28 Thread kavitha thankaian
Thanks Sanket,,, But still doesnt solve my problem,,, now my file contains: aa,ba,b,ca,b,c, and so on,,, the comma at the end is deleted,,,but the file contains some junk values,,, kavitha sanket kathalkar <[EMAIL PROTECTED]> wrote: Solution to this problem is: -

Re: newbie question(file-delete trailing comma)

2007-02-28 Thread Mikael Olofsson
kavitha thankaian wrote: > my script writes a dictionary to a file.but i need only the values > from the dictionary which should be sepearted by a comma,,,so i did as > following: > [snip code that generates the incorrect original file] > when i execute the above code,my test.txt file has the fol

Re: newbie question(file-delete trailing comma)

2007-02-28 Thread kavitha thankaian
ok,,, my script writes a dictionary to a file.but i need only the values from the dictionary which should be sepearted by a comma,,,so i did as following: some=getAllData()-->dictionary f=open("test.txt", "w") for value in some.values(): f.writelines('\%s\,' % value )

Re: newbie question(file-delete trailing comma)

2007-02-27 Thread Mikael Olofsson
kavitha thankaian wrote: > i get an error when i try to delete in file and rename it as out > file,,the error says > "permission denied". Perhaps you should give us both the exact code you are running and the complete traceback of the error. That could make things easier. There can be numerous re

Re: newbie question(file-delete trailing comma)

2007-02-27 Thread kavitha thankaian
i get an error when i try to delete in file and rename it as out file,,the error says "permission denied". actually i need something like following: in_file = open('in.txt','w') for line in in_file: line.strip().strip(',') but when i run the above code,i get an error"bad fi

Re: newbie question(file-delete trailing comma)

2007-02-26 Thread Mohammad Tayseer
kavitha thankaian <[EMAIL PROTECTED]> wrote: > and i need the output also in the same input.txt just add import os os.remove('in.txt') os.rename('out.txt', 'in.txt') - Don't be flakey. Get Yahoo! Mail for Mobile and always stay connected to friends.-- http://m

Re: newbie question(file-delete trailing comma)

2007-02-26 Thread kavitha thankaian
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??

Re: newbie question(file-delete trailing comma)

2007-02-26 Thread Robin Becker
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

Re: newbie question(file-delete trailing comma)

2007-02-26 Thread Mohammad Tayseer
in_file = open('in.txt') out_file = open('out.txt', 'w') for line in in_file: print >> out_file, line.strip(',') kavitha thankaian <[EMAIL PROTECTED]> 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

newbie question(file-delete trailing comma)

2007-02-26 Thread kavitha thankaian
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 - Here’s a new way to f