Postgresql copying data to a table

I use the copy command in Postgresql and I have a row of data in a text file that is divided into a tab and I would like to copy it to the db table.

I get the error message: ERROR: invalid byte sequence for encoding "UTF8": 0x00 SQL state: 22021 Context: COPY real_acct1, line 113038

So, I went to line 113038 from a text file and copied it along with 4 or 5 adjacent lines to a new text file and saw that the new data was included.

Any useful thoughts? This is parcel data attribute information.

+4
source share
1 answer

Your problem is actually one of the character encodings.

The easiest way to handle this is to run your import data via iconv (assuming you are on a Unix machine).

iconv -f original_charset -t utf-8 originalfile> newfile

+2
source

Source: https://habr.com/ru/post/1392241/


All Articles