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.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
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.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back