Solved: The integer column was set on auto increment, just left it empty on the import...
we have a lot of data, that is currently in excel. I made a VBA skript, that builds me a CSV to import into our Database / PostgreSQL Table. I'm trying to import with the import/export feature of PgAdmin.
The table has columns of type ([PK] Integer, string, string, JSON). When I try to import it throws me an error, right at the beginning, saying that »2« is no valid integer.
The file is UTF-8 encoded.
This is the command PgAdmin generates:
--command " "\copy public.stocknew (stockid, stockname, stockbarcode, stockjson) FROM '//DESKTOP-G86U473/temp/Test.csv' DELIMITER ',' CSV ENCODING 'UTF8' QUOTE '"' ESCAPE '''';""
Not a regular question asker, so please comment, if anything needs clarification.
Here is the first entry of the CSV file.
2,"W12345","35","{
'"Manufacturer'":'"ExampleValue'",
'"Supplier'":'"ExampleValue'",
'"SupplierName'":'"ExampleValue'",
'"Category'":'"ExampleValue'",
'"SubCategory'":'"ExampleValue'",
'"Partvalue'":'"868MHz - 928MHz, 2.400MHz - 2.500MHz'",
'"Tolerance'":'"ExampleValue'",
'"Dimension'":'"10,4 x 49,6mm'",
'"Temperature'":'"-34°C + 76°C'",
...*This keeps going for a while*...
'"Example'":2,
'"Example'":3,
'"Example'":4
}"
"is set as the encapsulating character. But, the JSON data doesn't escape"that are part of the data. In addition, I wouldn't use newline within a field value. JSON can load well without newlines.