I wrote a small script in Python to accept a csv file similar to what comes from Excel and output it as a pipe delimited file. When encountering a cell containing multiple lines, it currently adds a backslash (as that is what I specified as the escape character) at the end of the line and continues the cell on the next line. What I want to do though is be able to specify a space character or a string that the new line would be replaced with instead of the backslash and continue the record on the same line. I am having some trouble accomplishing this though. Is there an easy way to do this using the csv module? What I have so far:
fout = open (tfile, "wt")
cout = csv.writer(fout, delimiter = '|', quotechar = '', quoting = csv.QUOTE_NONE, lineterminator = '\n', escapechar='\\')
cin = csv.reader(fin)
for row in cin:
cout.writerow(row)