ERROR: extra data after last expected column on postgresql

13,282

Well, it's a pretty clear error message if you ask me.. your code told the database to expect 4 columns of data and then you provided a file with 9 columns of data..

Just because there is nothing between the last 5 commas doesn't mean it isn't data!

Clean up the file in a text editor and try again

Share:
13,282
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    When I import csv file I see the this error

    ERROR: extra data after last expected column SQL state: 22P04 Context: COPY everyhighschool, line 1: "B100005528,서울특별시,구암고등학교,구암고등학교,,,,,"

    My table

    CREATE table everyhighschool(
    schoolcode varchar(10),
    region varchar(20),
    shortschoolname varchar(30),
    schoolname varchar(30))
    

    My copy code

    COPY everyhighschool(schoolcode, region, shortschoolname, schoolname)FROM 'C:\Users\Administrator\Desktop\code.csv' WITH DELIMITER ',';
    
  • Admin
    Admin almost 7 years
    Thank you for your efforts.