user2793872
user2793872

Reputation: 319

getting error invalid byte sequence for encoding

I have table raw_ca_dd

When upload data into the table I get an error like:

invalid byte sequence for encoding "UTF8": 0xfb
\copy raw_ca_dd from 'dbo_CA_list.csv.dak' with delimiter ','  csv quote as '"'

I unable to find this error. Help?

Upvotes: 0

Views: 2623

Answers (1)

Craig Ringer
Craig Ringer

Reputation: 324265

I'd say your file is in a different encoding, like iso-8859-15, rather than utf-8, since 0xfb is invalid utf-8, but is û in many of the ISO 8859 encodings. It could also be , ϋ, ű, ћ, ū in various other ISO 8859 encodings. There are also a bunch of code-pages (eg cp1255) I didn't bother to check.

Find out what the correct encoding of your file is and specify it with the encoding parameter to the copy command, eg:

\copy raw_ca_dd from 'dbo_CA_list.csv.dak' with encoding 'iso-8859-1' delimiter ','  csv quote as '"' 

Don't assume it's iso-8850-15. Find out the actual text encoding of the input file and use that.

Upvotes: 3

Related Questions