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'

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?

Thanx in advance for your help

Best,
Oliveiros

Search Discussions

  • Sean Davis at Aug 24, 2007 at 12:14 pm

    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
  • Oliveiros Cristina at Aug 24, 2007 at 1:50 pm
    Thanks a million for the tips , Sean.
    I've already fixed it.

    Best,
    Oliveiros


    2007/8/24, Sean Davis <sdavis2@mail.nih.gov>:
    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

    ---------------------------(end of broadcast)---------------------------
    TIP 3: Have you checked our extensive FAQ?

    http://www.postgresql.org/docs/faq


    --
    "An equation for me has no meaning, unless it represents a thought of God."
    - Srinivasa Ramanujan Iyengar

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedAug 24, '07 at 12:06p
activeAug 24, '07 at 1:50p
posts3
users3
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase