Adding info to pgsql table from txt/cvs

Dark Atheist

OSNN Veteran Addict
Staff member
Political User
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


Political User
"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.

Dark Atheist

OSNN Veteran Addict
Staff member
Political User
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 :)


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.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
What a long strange trip it's been. =)

Forum statistics

Latest member