0

I'm using pgadmin 1.18. I have a copy of a table that I truncated. I simply want to load an import csv file which essentially looks like this:

20151228,12/28/2015,53,12,December,4,2015,1,Monday
20140828,08/28/2014,35,8,August,3,2014,4,Thursday
20150208,02/08/2015,6,2,February,1,2015,7,Sunday

I'm getting an error:

extra data after last expected column CONTEXT: COPY tblname, line 1: "20151228,12/28/2015,53,12,December,4,2015,1,Monday"

This is the first line it´s trying to import. Any suggestions on how to fix this?

2
  • Can you show the structure of the table you are importing into (\d {tablename} in psql) Commented Apr 24, 2015 at 21:55
  • ah..that explains it. I used the "Create Object of same type" button. Apparently, it created a table, with the same table name. But if I click on it, the create table looks has no columns and datatypes defined. Is there a way in pgadmin Commented Apr 24, 2015 at 22:03

1 Answer 1

3

From the comments it appears you were using the wrong function in pgadmin.

If you have an existing table, which you have truncated and wish to load from a CSV file, select the table and then use Tools => Import, select the file and choose format 'CSV'.

There are other options in the import dialog to allow you to skip specified columns, use different quoting options, and specify how to deal with NULL values.

One tip that always trips me up: make sure there is no blank line at the end of the file.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.