Adding info to pgsql table from txt/cvs

Dark Atheist

OSNN Veteran Addict
Political Access
Joined
8 Apr 2003
Messages
6,376
i have a txt file with a few companies names in and rather than put them in one by one (there are about 100+) i have been trying to use the compy command

COPY comanies FROM /usr/home/carpo/comp.txt

but it always comes back with a syntax error

ERROR: invalid input syntax for integer: "ABC Computers,"
CONTEXT: COPY comps, line 1, column comps_id: "ABC Computers,"

i have tried with a cvs file but some error remains
 
"ABC Computers" is not an integer, and as such can't be copied into an integer. The error is plainly telling you where it went wrong.

You will need to make a csv file that has a unique ID for every company.
 
well its not very clear on the pgsql website that's what i should do, and i used the line it gave me, and to be clear im not that great with sql - have only just started to learn it 🙂

edit

COPY comps (comp_id, comp_name) FROM '/home/carpo/comps.txt';
1 ABC Computers
etc etc

i believe should do it 🙂
 
Last edited:

Members online

No members online now.

Forum statistics

Threads
62,021
Messages
673,242
Members
5,640
Latest member
Kgkass
Back
Top