I am trying to import csv to postgres through c# code the query is i am guess right but i get error :
The query can't be executed!ERROR: 22P04: extra data after last expected column
My code to do this is:
string codes_colisage = "COPY code_colisage (REFERENCE_TRANSPORTEUR, CLIENT, PRODUIT, CODE_POSTAL_OU_DEPARTEMENT, IDENTIFIANT_LIEUX_LIVRAISON, REFERENCE_CODE_COLISAGE) FROM 'E:/MDE/KMP/App_Data/CSV/test_alpha/code_colisage.csv' WITH DELIMITER ';' ";
where the csv file contains this http://prntscr.com/9p1qqu and the DB has following columns http://prntscr.com/9p1qz2
How to fix such that i won't have this error again
NOTE: Please note that i have to import the data of these 6 tables only which i have mentioned in string.
Your C# string lists 6 database columns, the CSV file has 7 items in each row. This will not work in PostgreSQL. You can either delete the unwanted column of data in the CSV file using MS Excel, or add a dummy column to the table in the database and then drop that column after importing the data.