etnorias86
etnorias86

Reputation: 21

extra data after last expected column in postgres during csv import

I am trying to import a CSV file into postgres and getting the following error:

"C:\\Program Files\\PostgreSQL\\11\\bin\\psql.exe" --command " "\\copy public.prisons (english_prison_names, dari_prison_names, pashto_prison_names, characters_transmitted) FROM 'C:/Data/prisons.csv' CSV ENCODING 'UTF8' QUOTE '\"' ESCAPE '''';""

ERROR: extra data after last expected column CONTEXT: COPY prisons, line 1: "Badakhshan Prison Facility,زن دان ب دخ شان,ب د د خشا هناخ یدنب ن,BKN,,,..."

I have read multiple questions of this kind on stack already and have checked for any extra spaces in the data and I only have 4 columns in my CSV file, 4 columns created in my table.

sample of first few lines of CSV, it seems to be hung up already on the first line?

Badakhshan Prison Facility,زن دان ب دخ شان,ب د د خشا هناخ یدنب ن,BKN,,,,,,
Badghis Prison Facility,نز دا ب ن ا د سیغ,ب د ا د ب سیغ ن د ی هناخ,BDG,,,,,,
Baghlan Prison Facility,نز دا ب ن غا ل ن,ب د غا ل ب ن ن د ی هناخ,BGL,,,,,,

thanks in advance for any help

Upvotes: 1

Views: 408

Answers (1)

etnorias86
etnorias86

Reputation: 21

Figured it out! when i saved to CSV from excel for some reason it added all those extra commas at the end of each line, this led postgres to see them as empty columns, more columns than i prepared.

Upvotes: 1

Related Questions