PostgreSQL error using pgAdmin4 to upload csv file
You are getting the error because your CSV file has one less column(id) then the table. The COPY
command(which is being used by Import) has no idea that this field has a DEFAULT. In the Import dialog there should be a tab named Columns that allows you to select those columns that are in the CSV.
pgAdmin4: Importing a CSV
According to your table structure, this import will fail in the columns HEADING
and SPEED
, since their values have decimals and you declared them as INTEGER
. Either remove the decimals or change the column type to e.g. NUMERIC
.
Having said that, just try this from pgAdmin (considering that file and database are in the same server):
COPY i210_2017_02_18 FROM '/home/jones/file.csv' CSV HEADER;
In case you're dealing with a remote server, try this using psql
from your console:
$ cat file.csv | psql yourdb -c "COPY i210_2017_02_18 FROM STDIN CSV HEADER;"
You can also check this answer.
In case you really want to stick to the pgAdmin import tool, which I discourage, just select the Header
option and the proper Delimiter
:
Updating an imported CSV file in pgadmin4
Not sure if I fully understand as you mentioned "updating a CSV file" and not the table you created. Maybe use a staging table. Truncate the staging on each load. Join staging and main table - Jan21 - to find new data and only load new data. This may or may not be what you need.
Related Topics
Cte in from Clause of SQL Query
Postgres Column Does Not Exist
Oracle Show All Employees with Greater Than Average Salary of Their Department
Output Inserted.Id and Another Field
How to Change the Formatting for My Return Values in This Function
Why Postgres Is Not Using the Index in My Query
Search If Number Is Contained Within an Expression Like: 1-3,5,10-15,20
Bigquery Update Nested Array Field
Stored Procedure, Pass Table Name as a Parameter
How to Merge Two or More Rows Based on Their Foreign Key
Transposing SQLite Rows and Columns with Average Per Hour
Ssrs Remove Column from Report
Sql:Casting a String to Ids with in Clause
How to Obtain Unique Results from a Select with Joined Records