0

I get an error when trying to use copy utility to extract data from csv file with UCS-2 LE BOM encoding (as reported by notepad++).

COPY pub.calls (............ ) 
FROM 'c:\IMPORT\calls.csv'
WITH 
  DELIMITER ','
  HEADER
  CSV
  ENCODING 'UCS2'; 

The error is something like this

SQL Error [22023]Error The argument of encoding parameter should be acceptable encoding name.

UCS-2 gives the same error.

2
  • I would suggest you trying to use ENCODING 'UTF8'; ?.. I don't know if all UCS-2 codes match those in UTF, but I thought so for some reason... :) Commented Jan 11, 2018 at 12:45
  • UTF-8 gives wrong byte sequence.. Commented Jan 11, 2018 at 13:00

1 Answer 1

2

For the list of supported charsets: https://www.postgresql.org/docs/current/static/multibyte.html

or in psql type \encoding and dbl tab for autocomplete:

postgres=# \encoding
BIG5            EUC_JP          GB18030         ISO_8859_6      JOHAB           LATIN1          LATIN3          LATIN6          LATIN9          SJIS            UTF8            WIN1252         WIN1255         WIN1258
EUC_CN          EUC_KR          GBK             ISO_8859_7      KOI8R           LATIN10         LATIN4          LATIN7          MULE_INTERNAL   SQL_ASCII       WIN1250         WIN1253         WIN1256         WIN866
EUC_JIS_2004    EUC_TW          ISO_8859_5      ISO_8859_8      KOI8U           LATIN2          LATIN5          LATIN8          SHIFT_JIS_2004  UHC             WIN1251         WIN1254         WIN1257         WIN874
Sign up to request clarification or add additional context in comments.

3 Comments

No.. iconv is for linux and I use windows on this PC. Trying to do this with powershell..
ah, right, np++ - does not it convert itself? I recall it's extremely powerful. Probably my best experienced text processor
Yes, np++ can handle it, but I want to automate it. Now I use powershell script: Get-content -encoding "Unicode" 'c:\IMPORT\calls.csv' |out-file -encoding UTF8 'c:\IMPORT\calls_out.txt'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.