user2395365
user2395365

Reputation: 2149

How to do simple csv file COPY in Postgres

I have:

TAG_ID,TAGNAME,HH_INCEPT,ACCOUNTNUMBER,ACCT_START_DATE,ACCT_STOP_DATE,ORION_CLIENT_TRAIL
45298,JIM JONES,11/16/07,905413871,11/16/07,8/15/14,

My create table:

CREATE TABLE folio_groups
(
  id serial NOT NULL,
  tag_id integer NOT NULL,
  tagname character varying(50) NOT NULL,
  hh_incept date NOT NULL,
  accountnumber character varying(50) NOT NULL,
  acct_start_date date NOT NULL,
  acct_stop_date date,
  orion_client_trail integer
)

And I try:

# COPY folio_groups FROM '/tmp/folio.csv' CSV HEADER;

But get:

ERROR:  invalid input syntax for integer: "JIM JONE"
CONTEXT:  COPY folio_groups, line 2, column tag_id: "JIM JONE"

Any idea how to copy this simple CSV?

Upvotes: 0

Views: 53

Answers (1)

Nick Barnes
Nick Barnes

Reputation: 21306

COPY folio_groups (
  tag_id,
  tagname,
  hh_incept_date,
  accountnumber,
  acct_start_date,
  acct_stop_date,
  orion_client_trail
)
FROM '/tmp/folio.csv' CSV HEADER;

Upvotes: 2

Related Questions