pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Holger Jakobs <holger@jakobs.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: Invalid byte sequence
Date: Thu, 1 Jul 2021 09:40:19 +0200
Message-ID: <c30c40b2-721f-7fb9-7973-4a65f89d8e4b@jakobs.com> (raw)
In-Reply-To: <CALhHtcC1zP2ADshm_Qo=RHHsTyqhR0jErAydPBZf2-ZbUrFLWg@mail.gmail.com>
References: <CALhHtcC1zP2ADshm_Qo=RHHsTyqhR0jErAydPBZf2-ZbUrFLWg@mail.gmail.com>

How many lines has the file? Maybe line 377617 is the last one.

If so, you can just remove the last line containing this 0x00. The 
following command can do this for you:

|sed -i '$ d' |/outputfile.csv

May I remark that having a file in the / directory is a bit awkward? 
This directory should not be writable by any user (except root, and root 
doesn't fiddle with files for a database).



Am 01.07.21 um 09:29 schrieb Yambu:
> Hello
>
> How do i get past the error below. I have created a foreign table 
> which points to a csv file and when i try to create another table it 
> gives error below
>
> The csv file has funny characters, how do i bypass those characters.
>
> create foreign table table1
> (
> id int,
> name text
> )
> SERVER local_file
> OPTIONS (filename '/outputfile.csv' ,
> format 'csv',
> header 'TRUE',
> delimiter ';'
> );
>
>
> create table2 as select * from table1;
>
> ERROR:  invalid byte sequence for encoding "UTF8": 0x00
> CONTEXT:  COPY table1, line 377617

-- 
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012

Attachments:

  OpenPGP_signature (application/pgp-signature, 202B) download

view thread (9+ messages)  latest in thread

Message-ID: <c30c40b2-721f-7fb9-7973-4a65f89d8e4b@jakobs.com>
Permalink:  ../c30c40b2-721f-7fb9-7973-4a65f89d8e4b@jakobs.com/
Also on:    postgresql.org/message-id/c30c40b2-721f-7fb9-7973-4a65f89d8e4b@jakobs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: holger@jakobs.com, pgsql-admin@lists.postgresql.org
  Subject: Re: Invalid byte sequence
  In-Reply-To: <c30c40b2-721f-7fb9-7973-4a65f89d8e4b@jakobs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox