[Babase] another postgresql question

Karl O. Pinc kop at meme.com
Thu Feb 22 02:01:42 EST 2007


On 02/21/2007 08:46:20 PM, Susan Alberts wrote:
> Hi again,
> I have a csv file that i want to import into my schema. I created a  
> table in my schema with the appropriate number of columns, then  
> selected it and chose "import" from the last of tabs on the top. I  
> chose the csv file in question, clicked Import, and it said "import  
> successful" or something like this. The table still had zero rows.  
> What am i missing?
> 
> I tried the postgresql website but I am not very conversant with that  
> yet and didn't get far.

The place to look would be the ppa website, and I don't think
you'll find help on that there.

It's hard to say what you're missing from here.  I could look at the
data and the table you made and try it myself.

As a random guess, the file uploaded to papio (and you got a message)
but there was a datatype mis-match between the data
and the columns of your table which is why it didn't make
it in.

I worked out
an import procedure with Leah that worked.  You could try that.

What we did was use the sql window and the COPY command.
(For the COPY command docs see:
http://www.postgresql.org/docs/8.1/static/sql-copy.html
The procedure below uses "Text formatted" data.)

IIRC we put the following COPY command in the first line
of the SQL window:

COPY mytablename FROM STDIN

Then we selected all the rows to import from a spreadsheet
with the mouse and did a COPY/PASTE operation to put
the rows after the above COPY command.  (This put
the data into the window using tabs as a separator
between columns.)

Then at the bottom of all the data we put the following
2 lines:

\.
;


(I think maybe the semicolon could be left off.)

Then hit the button that executes the query.

If that doesn't work I'd expect to get a useful
error message.

There's a way to do it from a file too but I don't
recall it well enough to type it out right now,
and I recall Leah had problems saving things as a file
which is why we did it this way.

(Note you can't
COPY mytable FROM FILE 'foo'
directly unless the "foo" file is on papio.)

Send me the file off-list if you want me to look
at it.


Karl <kop at meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein



More information about the Babase mailing list