I have a CSV that visually does not look broken. One of the column contains full emails and subsequently additional commas. The format is something like:
ID | Info | Email | Notes
--------------------------------------------------
1234 | Sample | Full email here,| More notes here
| and email wraps.|
--------------------------------------------------
5678 | Sample2| Another email, | More notes
--------------------------------------------------
9011 | Sample3| More emails | Etc.
--------------------------------------------------
I am using the CSV reader which is outputting each new line as a new row and it is incorrect. For example, I am getting:
Line 1: 1234 | Sample | Full email here,| More notes here
Line 2: | and email wraps.|
Line 3: 5678 | Sample2| Another email, | More notes
Line 4: 9011 | Sample3| More emails | Etc.
I need it to be able to recognize the cell delimiters just as Excel or Libre Office do, and get this:
Line 1: 1234 | Sample | Full email here, and email wraps.| More notes here
Line 2: 5678 | Sample2| Another email, | More notes
Line 3: 9011 | Sample3| More emails | Etc.
I have this code:
import csv
import sys
csv.field_size_limit(sys.maxsize)
file = "myfile.csv"
with open(file, 'rU') as f:
freader = csv.reader(f, delimiter = '|', quoting=csv.QUOTE_NONE)
for row in freader:
print(','.join(row))
I tried delimiter = ',' or delimiter = '\n' but no luck. Any ideas?