phillyooo phillyooo - 1 year ago 130
R Question

Importing csv file with line breaks to R or Python Pandas

I have a csv file that includes line breaks within columns:


ID 3, for example contains such a line break.

How can this be imported into python or R? Also, I don't mind if those line breaks were to be replaced by a space, for example.

Answer Source

Python has built-in CSV reader which handles that for you. See csv documentation.

import csv

with open(filename) as f:
    reader = csv.reader(f)
    csv_rows = list(reader)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download