“extra data after last expected column” while trying to import a csv file into postgresql

后端 未结 3 1141
栀梦
栀梦 2020-12-29 02:02

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



        
3条回答
  •  心在旅途
    2020-12-29 02:08

    Now you have 7 fields.

    You need to map those 6 fields from the CSV into 6 fields into the table.

    You cannot map only 3 fields from csv when you have it 6 like you do in:

    \COPY agency (agency_name, agency_url, agency_timezone) FROM 'myFile.txt' CSV HEADER DELIMITER ',';
    

    All fields from the csv file need to to be mapped in the copy from command.

    And since you defined csv , delimiter is default, you don't need to put it.

提交回复
热议问题