Skip site navigation (1) Skip section navigation (2)

Re: How to import a csv

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: Oliveiros Cristina <oliveiros(dot)cristina(at)marktest(dot)pt>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to import a csv
Date: 2007-08-24 12:14:38
Message-ID: 46CECBAE.6070201@mail.nih.gov (view raw or flat)
Thread:
Lists: pgsql-novice
Oliveiros Cristina wrote:
> Hi, I am trying to import a file into a table.
>  
> The file has the form
> integer, string
> integer, string
>  
> Table has 5 columns, but I just need to fill the first two, the others
> can remain blank
>  
> I've tried COPY table1 FROM 'C:\\file.txt'

You will need to include the column names into which you want to insert
the data.

> But PGAdmin ||| complains
> with the following :
> ERROR: invalid input syntax for integer: " 319613 , Sapo  "
> SQL state: 22P02
>  
> 319613 , Sapo is the very first line of the file.
> It seems that it is trying to put the pair (integer, string) in the
> first column alone
>  
> How can I fix this?

You need to specify the delimiter.  I would suggest looking at the
documentation here:

http://www.postgresql.org/docs/8.2/static/sql-copy.html

Sean

In response to

Responses

pgsql-novice by date

Next:From: Oliveiros CristinaDate: 2007-08-24 13:50:42
Subject: Re: How to import a csv
Previous:From: Oliveiros CristinaDate: 2007-08-24 11:50:58
Subject: How to import a csv

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group