I get a UTF encoding error when trying to copy data from a csv file
Error invalid by sequence for encoding...
SQL State: 22021
Context Copy mydatabase line 165
I am wondering if it is possible to skip over the line(s) that throws the error. I am aware that is possible to skip the first line using the header
command but the line I get isn't in the first row. I'd like to find a solution inside of Postgres rather than one that has me going into another program.
Unfortunately, that functionality hasn't been integrated into PostgreSQL. The quickest workaround I know of is to use sed to filter out bad input lines. If you really must keep the solution PostgreSQL-based, I know of no alternative to using PL/pgsql or another procedural language interface to read in your data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With