postgress SQL state: 22P02

Viewed 264

i have been trying to import this csv ino psql: COPY isse FROM'C:\Users\Owner\Desktop\nnn.csv'DELIMITER ',' HEADER CSV

and this error about "2,033" which has thousand comma popped up

also i need to work on numbers over thousand which definitely has comma.

ERROR: invalid input syntax for type integer: "2,033" CONTEXT: COPY isse, line 12, column monthly_sales: "2,033" SQL state: 22P02

1 Answers

First create the table structure accordingly. Then use :

\COPY <table name> FROM 'location + file_name' DELIMITER ',' CSV HEADER;

where:

\COPY: This is the command to copy the record to / from the .csv file.

<table_name>: Provides the table name where you want to import the data.

'location + file_name': An absolute path to the file (make sure you have read access to the file).

DELIMITER ',': Specifies the delimiter, which in our case is a comma: ‘,’.

CSV Specifies the file type from which we are going to import.

HEADER Signifies that we have a header row in our .csv file and while importing we should ignore the first row

Related