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
 

X-Istence

*
Political Access
Joined
5 Dec 2001
Messages
6,498
"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
Political Access
Joined
8 Apr 2003
Messages
6,376
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.

Latest forum posts

Latest profile posts

Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.
Terrahertz wrote on Electronic Punk's profile.
Yo fellas!
Electronic Punk wrote on Sazar's profile.
Where are you buddy?
Perris Calderon wrote on Electronic Punk's profile.
Hey EP! All good with me, applying for Microsoft MVP right now, should have done this a while ago.

Notifications don't work, I only found your response by coming back to hunt up some threads, if you want, give me your email address so we can keep in touch easier!
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!

Forum statistics

Threads
61,997
Messages
673,412
Members
5,591
Latest member
nodee