cdecarlo wrote:
> Hello,
>
> I've often found that I am writing little scripts at the interpretor to
> read a text file, perform some conversion, and then write the converted
> data back out to a file. I normally accomplish the above task by
>
> Any suggestions,
>
> Colin
You should check out
See also this recent discussion on techniques for making sure you get
the file closed, even if there is an exception.
http://tinyurl.com/fryrv
rd
--
http://mail.python.org/mailman/listinfo/python-list
Whoops:
> outfile = open(out_f)
outfile = open(out_f, 'w')
may be better ;-)
--
http://mail.python.org/mailman/listinfo/python-list
> cdecarlo <[EMAIL PROTECTED]> writes:
> fout = open('somefile','w')
> for line in convertedData:
> fout.write("%s\n" % line)
> fout.close()
> -- or --
> fout = open('somefile','w')
> fout.write("%s" % '\n'.join(convertedData))
> fout.close()
> ... or maybe some hybrid of the two which
> fout = open('somefile','w')
> for line in convertedData:
> fout.write("%s\n" % line)
> fout.close()
>
> -- or --
>
> fout = open('somefile','w')
> fout.write("%s" % '\n'.join(convertedData))
> fout.close()
I shouldn't think it matters too much which of these you use - time
them and see what h
cdecarlo wrote:
>
> fout = open('somefile','w')
> for line in convertedData:
> fout.write("%s\n" % line)
> fout.close()
>
> -- or --
>
> fout = open('somefile','w')
> fout.write("%s" % '\n'.join(convertedData))
> fout.close()
>
I'd go for something like...
fout = open('somefile','w')
fout.wri
Hello,
I've often found that I am writing little scripts at the interpretor to
read a text file, perform some conversion, and then write the converted
data back out to a file. I normally accomplish the above task by
reading the lines of the entire file into a list, preforming some
function to that