On Feb 15, 1:11 pm, Albert-jan Roskam <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a csv file with tab as a delimiter. I want to > convert it into one that is comma delimited. I changed > the regional settings on my computer to US. > > At first I thought I could use the CSV module for > this, by reading the csv file, registering the new > (desired = comma-delimited) dialect, and writing it. > > Another option (which may be easier) I tried was: > f = open('d:/temp/myfile.csv', ' rw') > for row in f: > row.replace("\t",",") > > Which is a start, but doesn't do the entire job. > Could somebody help me with this please? > > Thanks very much in advance! > > Albert-Jan > > > ____________________________________________________________________________________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
easiest way would be to split and then join imo for line in input_file: output_file.write(','.join(line.split('\t')) ) If you decide on quote encapsulated comma-delimeted, don't forget to add additional quotes to the start and end of the line. Also, if you open the file in OO Calc and you choose to resave it you can choose the delimiter. -- http://mail.python.org/mailman/listinfo/python-list