Re: Copy entire file as one field

From: "Devinder K Rajput" <Devinder(dot)Rajput(at)ipaper(dot)com>
To: "Warren Massengill" <warrenmassengill(at)hotmail(dot)com>
Cc: olly(at)lfix(dot)co(dot)uk, pgsql-novice(at)postgresql(dot)org, pgsql-novice-owner(at)postgresql(dot)org
Subject: Re: Copy entire file as one field
Date: 2002-12-03 22:17:40
Message-ID: OFAADBCCDB.29F8F5DF-ON86256C84.007A3867@ipaper.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


Warren,

merge is an actual linux utility used to merge files. When you ran the
command it found the system command before it could get to your script. To
run your program, cd to the your program is stored. Then type in
./merge

This will execute the program in your current directory. This should do
the trick,

Devinder


"Warren Massengill"
<warrenmassengill(at)hotm To: olly(at)lfix(dot)co(dot)uk
ail.com> cc: pgsql-novice(at)postgresql(dot)org
Sent by: Subject: Re: [NOVICE] Copy entire file as one field
pgsql-novice-owner(at)pos
tgresql.org


12/03/2002 01:48 PM

My database is pg, the table is mail.
The small text files are in /home/kelly/message/.
The bash shell script is merge.

Somehow I failed to translate your instructions...

-----------------------------------------------------
#!/bin/bash

for f in `ls /home/kelly/message*`
do
psql -d pg -c "INSERT INTO mail (message)
VALUES ('`cat $f`')"
done

----------------------------------------------------
[kelly(at)localhost message]$ merge
merge: not enough arguments
merge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2
file3
merge aborted

----------------------------------------------------
Thanks,
Warren

>From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
>To: Warren Massengill <warrenmassengill(at)hotmail(dot)com>
>CC: pgsql-novice(at)postgresql(dot)org
>Subject: Re: [NOVICE] Copy entire file as one field
>Date: 28 Nov 2002 07:43:12 +0000
>
>On Thu, 2002-11-28 at 00:40, Warren Massengill wrote:
> > How can I copy several hundred small text files into a database, each
>file
> > going into a field called 'message' and becomming one record (with or
> > without other fields) using psql?
>
>A bit of shell scripting:
>
>for f in `ls small_file*`
>do
> psql -d mydatabase -c "INSERT INTO mytable (message)
> VALUES ('`cat $f`')"
>done
>
>
>--
>Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
>Isle of Wight, UK http://www.lfix.co.uk/oliver
>GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
> ========================================
> "The earth is the LORD'S, and the fullness thereof; the
> world, and they that dwell therein." Psalms 24:1
><< signature.asc >>

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Browse pgsql-novice by date

  From Date Subject
Next Message Joshua Daniel Franklin 2002-12-03 22:43:16 Re: Detecting table/row locks
Previous Message Oliver Elphick 2002-12-03 22:03:21 Re: Copy entire file as one field