Invalid byte sequence for encoding “UTF8”: 0xf8

While uploading data from a csv file to PostgreSQL database using COPY command, you might encounter error — Invalid byte sequence for encoding “UTF8”: 0xf8

The solution is to add encoding option.

psql=# \copy mytable(id,name,age,location) from '/path/to/file.csv' with delimiter ',' csv header encoding 'windows-1251';

--

--