I try to copy the content of a CSV file into my postgresql db and I get this error "extra data after last expected column".
The content of my CSV is
agency_id,agency_name,agency_url,agency_timezone,agency_lang,agency_phone
100,RATP (100),http://www.ratp.fr/,CET,,
and my postgresql command is
COPY agency (agency_name, agency_url, agency_timezone) FROM 'myFile.txt' CSV HEADER DELIMITER ',';
Here is my table
CREATE TABLE agency (
agency_id character varying,
agency_name character varying NOT NULL,
agency_url character varying NOT NULL,
agency_timezone character varying NOT NULL,
agency_lang character varying,
agency_phone character varying,
agency_fare_url character varying
);
Column | Type | Modifiers
-----------------+-------------------+-----------
agency_id | character varying |
agency_name | character varying | not null
agency_url | character varying | not null
agency_timezone | character varying | not null
agency_lang | character varying |
agency_phone | character varying |
agency_fare_url | character varying |
,
delimiter, thecopy
command parsed more fields than the destination table! Can you please bring your destination table data structure and samples of your CSV content ? – Averroism6
– Averroismcopy
command can't handle column selection from your file. In other words, you can only copy whole file at once! – AverroismCOPY agency (agency_id, agency_name, agency_url, agency_timezone,agency_lang,agency_phone) FROM 'myFile.txt' CSV HEADER DELIMITER ',';
– Averroism