I'm trying to import csv file into PostgreSQL table (9.2). I get error that one column value has wrong input syntax, but it seems PostgreSQL mismatches columns and its values.
I'm importing CSV with this command:
\copy project_task from '/home/user/downloads/project_task_export.csv' WITH DELIMITER ',' CSV HEADER
Error looks like this:
ERROR: invalid input syntax for integer: "4.25"
CONTEXT: COPY project_task, line 3, column sequence: "4.25"
My csv data looks like this:
id,create_uid,create_date,write_date,write_uid,remaining_hours,date_start,description,sequence,date_end,active,planned_hours,partner_id,delay_hours,user_id,name,date_deadline,notes,type_id,company_id,priority,total_hours,state,progress,user_group_id,project_id,effective_hours,context_id,timebox_id
185,8,2012-06-05 09:51:09.562849,2012-09-10 08:52:05.789792,26,4.25,2012-06-19 15:54:07,"asdcxzzsrt ab cdefgqwer tyuipok asmmdmksa kmsaaqqwerr.
",10,,t,12,,0.0,6,byrteqwas oeirklm askeiurjqqpl,,,,1,2,12.0,open,64.579999999999998,,9,7.75,1,4
If you looked closely in this CSV data and error, column sequence is 9th column, and error showed looks like PostgreSQL uses 6th columns value for nine column. Why it is doing it? Or maybe I'm doing something wrong?
\d project_task
as this will show the order of the columns. I would also suggest getting rid of theDELIMITER ','
since you are also specifying CSV (and thus it is the default) – Chris Travers Mar 7 at 14:30