0

I create custom Database with UTF-8 Encoding in postgreSQL (PHPPgAdmin) and create CSV file with Excel in windows too. I want to import CSV file to one of my table. When I open my csv file in Windows, some characters in the form Are shown with ? symbol. My CSV file has UTF-8 encoding. when I run Query to Import Data from That CSV file PostgresSQL with this command

COPY persons(first_name, last_name, dob, email)
FROM 'C:\sampledb\persons.csv'
DELIMITER ','
CSV HEADER;

It shows error : ERROR: invalid byte sequence for encoding "UTF8": 0xc2 0xd0 How can I insert my file into a table without corrupting its characters utf-8 encoding? thank you

  • 0xc2 0xd0 is not a valid utf8 sequence, so your CSV file is not utf8 encoded. Possibly CP1252 (improbable) or some other windows dialect. – wildplasser Jan 06 '21 at 13:09
  • Once you do figure out the encoding of the CSV file, `COPY` has an `ENCODING` option where you can specify it on import. Otherwise Postgres uses the client encoding. – Adrian Klaver Jan 06 '21 at 16:16

0 Answers0