Postgresql csv copy unquoted newline found in data
I have csv data in excel and I am importing it into postgresql. I open the excel csv file using notepad editor (tried notepad, wordpad and notepad ++) and then copy / paste on a remote desktop connection to a Linux machine. Then I use this import statement from the database: COPY ltg_data FROM '/home/keene/ltg_db/ltg_outbreak_jun9_15.csv' (FORMAT CSV, HEADER);
I am getting this error: ERROR: Unspecified newline found in data TIP. Use the quoted CSV field to represent the newline. CONTEXT: COPY ltg_data, line 175320
Here's a link to the csv file I'm using: http://greenandtheblue.com/ltg_outbreak_jun9_15.csv
I've done a lot with this issue and tried a lot, and I need to skip something pretty simple. Any help is greatly appreciated.
source to share
The file you linked does not have CR-LF line endings, however I suspect this might be a problem as you are coming from a Windows host. You can try removing the carriage return with sed
:
sed 's/\r//' ltg_outbreak_jun9_15.csv ltg_outbreak_jun9_15-noCR.csv
Then COPY FROM from the resulting file ...- noCR.csv.
source to share