I have a large CSV file with one column and line breaks in some of its rows. I want to read the content of each cell and write it to a text file but the CSV reader is splitting the cells with line breaks into multiple ones (multiple rows) and writing each one to a separate text file.
Using Python 3.6.2 on a MAC Sierra
Here is an example:
"content of row 1"
"content of row 2 continues here"
"content of row 3"
And here is how I am reading it:
with open(csvFileName, 'r') as csvfile:lines= csv.reader(csvfile)i=0for row in lines:i+=1content= rowoutFile= open("output"+str(i)+".txt", 'w')outFile.write(content)outFile.close()
This is creating 4 files instead of 3 for each row. Any suggestions on how to ignore the line break in the second row?