Reputation: 1
I'm very unfamiliar with SQL. This is my first time really using it.
I'm trying to import sales data (CSV), but keep getting this error when trying to import a csv file:
ERROR: invalid input syntax for type integer: "SalesID"CONTEXT: COPY sales_data, line 1, column salesid: "SalesID"
I created a table:
CREATE TABLE sales_data
(
salesid SERIAL PRIMARY KEY,
customerid INT,
productid INT,
sale_date DATE,
sale_amount INT
);
I've also tried:
CREATE TABLE sales_data
(
salesid INT,
customerid INT,
productid INT,
sale_date DATE,
sale_amount INT
);
I'm not even sure if I did that correctly, but it seems so to me.
I can't get past this error for each table I make.
I create the table, right click and use the import/export option. I get the error when I try importing.
I'm using PostgreSQL.
Upvotes: 0
Views: 85
Reputation: 247270
To skip a header line in a CSV file during import, use the HEADER
option:
COPY tab FROM 'somefile' (FORMAT 'csv', DELIMITER ';', HEADER);
Upvotes: 3