Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to import in format CSV chars as ñ, Ã in PostgreSQL

i have a problem with to import this format CSV file by your encoding

my query is:

\copy tablename from " path of the file.csv" DELIMITERS ';' CSV

OR

\copy tablename from " path of the file.csv" DELIMITERS ';' CSV header encoding 'UTF8'

OR

\copy tablename from " path of the file.csv" DELIMITERS ';' CSV header encoding 'WIN1252'

but, doesn´t insert the file data because it has an error

"error: character to byte 0x8d sequence encoding UTF8" OR
"error: character to byte 0x8d sequence encoding WIN1252"

these errors output are because I have chars Ñ,Ã and other

what type of encoding should I use?

like image 553
Nelson Jean Pierre Avatar asked Feb 28 '15 23:02

Nelson Jean Pierre


1 Answers

I resolved the problem was to place the latin1 encoding

so: \copy tablename(column1, colum2.. columnN) FROM 'path_file.csv' DELIMITER ';' NULL AS ' ' CSV header encoding 'latin1';

like image 69
Nelson Jean Pierre Avatar answered Nov 15 '22 04:11

Nelson Jean Pierre