Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres COPY FROM csv file- No such file or directory

Tags:

I'm trying to import a (rather large) .txt file into a table geonames in PostgreSQL 9.1. I'm in the /~ directory of my server, with a file named US.txt placed in that directory. I set the search_path variable to geochat, the name of the database I'm working in. I then enter this query:

COPY geonames FROM 'US.txt', DELIMITER E'\t', NULL 'NULL'); 

I then receive this error:

ERROR: could not open file "US.txt" for reading: No such file or directory. 

Do I have to type in \i US.txt or something similar first, or should it just get it from the present working directory?

like image 871
nerdenator Avatar asked May 17 '13 21:05

nerdenator


1 Answers

Maybe a bit late, but hopefully useful:

Use \copy instead

https://wiki.postgresql.org/wiki/COPY

jvdw

like image 167
jvdw Avatar answered Sep 20 '22 09:09

jvdw