3
votes

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 ',';
1

1 Answers

1
votes

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