Azar_Javed
Azar_Javed

Reputation: 75

Why do I get the "extra data after last expected column' when importing .csv into my database?

Ok, I've managed to solve the problem. I had comas on the problematic lines which was causing the script to not run. I had to go through each one to fix it, but it worked in the end. Thanks

I created a table using

CREATE TABLE customers_transfer
(
  customer text,
  phone text,
  alt_phone text,
  fax text,
  street1 text,
  street2 text,
  city text,
  state text,
  zip text,
  email text,      
)
WITH (
  OIDS=FALSE

);

and I have a .csv file that matches it. But when I try running COPY customers_transfer FROM 'C:/customer_transfer.csv' DELIMITER ',' I get this error. I've tried adding a single ',' to every last line but it still happens.

Access America Transport,423.821.8044,,423.678.7782,"2515 East 43rd St, Suite B",,Chattanooga,TN,37407,[email protected]

Upvotes: 3

Views: 30863

Answers (1)

Bruno
Bruno

Reputation: 641

it should be

COPY customers_transfer FROM 'C:/customer_transfer.csv' CSV

the DELIMITER ',' makes it split the text "2515 East 43rd St, Suite B" into two columns

Upvotes: 9

Related Questions