Re: Using psql to feed a file line by line to a table column - Mailing list pgsql-general

From Ian Lawrence Barwick
Subject Re: Using psql to feed a file line by line to a table column
Date
Msg-id CAB8KJ=jn8TEOBVqFuQNGGjzHggPE8Gwsj747t0r9++jXEGGp2Q@mail.gmail.com
Whole thread Raw
In response to Using psql to feed a file line by line to a table column  (Alexander Farber <alexander.farber@gmail.com>)
Responses Re: Using psql to feed a file line by line to a table column
List pgsql-general
2013/3/13 Alexander Farber <alexander.farber@gmail.com>:
> Hello,
>
> I have a list of 400000 non-english words,
> each on a separate line and in UTF8 format,
> which I'd like to put in the "word" column
> of the following table (also in UTF8 and 8.4.13):
>
> create table good_words (
>         word varchar(64) primary key,
>         verified boolean not null default false,
>         stamp timestamp default current_timestamp
> );
>
> Is there maybe a psql trick for that
> (the "psql --help" doesn't mention
> an "input field separator" option)?
>
> Or do I have to write a Perl-script for that task?

This should work from psql:

\copy good_words(word) from '/path/to/file.txt'

HTH

Ian Barwick


pgsql-general by date:

Previous
From: Alexander Farber
Date:
Subject: Using psql to feed a file line by line to a table column
Next
From: Alexander Farber
Date:
Subject: Re: Using psql to feed a file line by line to a table column