I have a csv file that includes line breaks within columns:
"id","comment","x"
1,"ABC\"xyz",123
2,"xyz\"abc",543
3,"abc
xyz",483
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.
You can also use python pandas library read_csv function. Make sure to specify escape char.
import pandas as pd
df = pd.read_csv('path_to_csv', sep=',', escapechar='\\')
Please note second backslash escaping first one. It has nothing to do with pandas or csv.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With