Обсуждение: invalid input syntax for integer

Поиск
Список
Период
Сортировка

invalid input syntax for integer

От
James Nobles
Дата:
I've just created my first table and I'm trying to load date into it via
the \copy command. Each time i get the invalid input syntax, no matter
what the type for the column is set too. I've tried int,integer and now
numeric.

Column    |         Type          | Modifiers
-------------+-----------------------+-----------
 county_code | integer               |
 cntyname    | character varying(30) |

 \copy fips_codes_county FROM '/var/lib/pgsql/files/county.csv' USING
DELIMITERS ','

This is a sample of the file i'm attempting to load, a simple ascii/csv
file.

 cat county.csv|more
county_code,cntyname
1,ANDERSON
3,ANDREWS
5,ANGELINA
7,ARANSAS
9,ARCHER
11,ARMSTRONG
13,ATASCOSA
15,AUSTIN
17,BAILEY
19,BANDERA
21,BASTROP
23,BAYLOR
25,BEE
27,BELL
29,BEXAR
31,BLANCO

thanks...


Re: invalid input syntax for integer

От
Tom Lane
Дата:
James Nobles <james@bolshevikhosting.com> writes:
> This is a sample of the file i'm attempting to load, a simple ascii/csv
> file.

>  cat county.csv|more
> county_code,cntyname
  ^^^^^^^^^^^

Well, that isn't a valid integer, is it?

In PG 8.1 you'll be able to say "CSV HEADER" to make it ignore the first
line of COPY input, but in existing releases I believe there's no
alternative but to remove the header line.

            regards, tom lane