In this post it's outlined how to copy the contents from a csv in a .gzip file into a postgresql table: Importing zipped CSV file into PostgreSQL.
copy tp from program 'zcat /tmp/tp.csv.gz';
My question is whether it's possible to also convert the encoding of the csv file within the gzip, as shown here invalid byte sequence for encoding "UTF8"
so something like this:
copy tp from program 'iconv -f original_charset -t utf-8 zcat /tmp/tp.csv.gz > stdin';
I get the following error when applying copy from with zcat:
psycopg2.errors.CharacterNotInRepertoire: invalid byte sequence for encoding "UTF8": 0xba CONTEXT: COPY tp, line 677117
When unpacked the csv file is encoded as ASCII
file tp.csv