I am trying to import data into my postgres table using \copy from a CSV file
The data is as follows:
1,2,"First Line \n Second Line", "Some other data"
insert into table (col1, col2, col3, col4) values (1, 2, E'First Line \n Second Line', 'Some other data')
The only thing you can escape in CSV is the field delimiter (
" by default) which you escape by doubling it.
Line breaks cannot be escaped, and indeed it is not necessary, as you can just use a literal line break.
This is a single line in CSV:
1,2,"First Line Second Line", "Some other data"