I have a CSV file that contains extra newlines in some fields, e.g.:
A, B, C, D, E, F
123, 456, tree
, very, bla, indigo
I tried the following:
import csv
catalog = csv.reader(open('test.csv', 'rU'), delimiter=",", dialect=csv.excel_tab)
for row in catalog:
print "Length: ", len(row), row
and the result I got was this:
Length: 6 ['A', ' B', ' C', ' D', ' E', ' F']
Length: 3 ['123', ' 456', ' tree']
Length: 4 [' ', ' very', ' bla', ' indigo']
Does anyone have any idea how I can quickly remove extraneous newlines?
Thanks!