On Sun, 30 Jan 2005 20:21:49 -0800, rasdj wrote: > Thanks Jeremy, something like this would work: > > try: > lines = [ line.replace(",\n;", ")\n;") for line in input ] > > If I could figgure out how to: > > IF ':' in line > READ next line in > lines = [ line.replace(",\n;", ")\n;") for line in input ] > output.write(str.join('', lines)) > > because there are lots of "comma newline" but the only ones I want are > the ones that follow the semicolon. > > RasDJ
My apologies, I was unclear when I said "suck the whole file in"; a little too colloquial. ------------- filename = "YOUR_FILENAME_HERE.sql" output = "YOUR_DESTINATION_HERE.sql" f = open(filename) contents = f.read() f.close() contents = contents.replace(",\n;", ")\n;") # optionally, the \n in the second string may be dropped, it isn't # necessary f = open(output, "w") f.write(contents) f.close() ------------ In other words, no mucking around with "lines" at all. You're better off thinking of the file as a flat stream of bytes in this case. -- http://mail.python.org/mailman/listinfo/python-list