0

I am having trouble importing a file. The table (us_counties_2010) has already been created and the file (us_counties_2010) is in the specified directory. According to the book I am reading, the following piece of code should import the file onto the table.

copy us_counties_2010
FROM 'C:\Users\julia\Desktop\us_counties_2010'
WITH (FORMAT CSV, HEADER);

I am getting the following error message:

ERROR:  could not open file "C:\Users\julia\Desktop\us_counties_2010" for reading: No such file or directory
HINT:  COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.<br>
SQL state: 58P01

In pgAdmin 4 expanding servers(1) results in "EDB Postgres Advance Server 12" but the book has "PostgreSQL 10." I am not sure if this is indicative of running it locally or not.

Attempted the built-in import tool in pgadmin, but with no success:

enter image description here

Server version: 12.1

Matthew
  • 45
  • 1
  • 9
  • Do you have Postgres running locally on your computer? And if you have, does the user account under which the Windows service runs have read access to the specified folder? –  Dec 28 '19 at 09:21
  • I followed this tutorial: https://www.youtube.com/watch?v=pl59ODaP6no. It hadn't been placed for everyone and full control. Still not working. Furthermore, I am using port 5432. – Matthew Dec 28 '19 at 09:39
  • take a look at this: https://stackoverflow.com/questions/50751203/pgadmin4-importing-a-csv/50756503#50756503 – Jim Jones Dec 28 '19 at 10:51
  • Tried the built-in import tool. – Matthew Dec 28 '19 at 11:41
  • Under the heading of Question your basic assumptions, is the file name "C:\Users\julia\Desktop\us_counties_2010" or perhaps "C:\Users\julia\Desktop\us_counties_2010.csv" – Belayer Dec 28 '19 at 16:06
  • The first one, without the csv. Do the column names need to be exactly the same ? The spelling of the column names for the file and the table that was created differ. Wondering if this is another issue – Matthew Dec 28 '19 at 19:00

0 Answers0