Unix Technical Forum

convert text file to database

This is a discussion on convert text file to database within the pgsql Novice forums, part of the PostgreSQL category; --> Readers, I re-formatted an extract from my file of chess matches to: Event,Online Game,Site, http://www.flyordie.com,Date,yyyy/mm...l,1200,moves,1 . c4 e5...25. Qh7# ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 06:20 AM
e-letter
 
Posts: n/a
Default convert text file to database

Readers,

I re-formatted an extract from my file of chess matches to:

Event,Online Game,Site,http://www.flyordie.com,Date,yyyy/mm...l,1200,moves,1.
c4 e5...25. Qh7# 1-0
Event,Online Game,Site,http://www.flyordie.com,Date,2008/01...l,1200,moves,1.
d4 d5...33. Bf3 Rxe5 0-1

I tried to import the csv file using the command:

chessmatches=# COPY chessgames FROM '/absolute/path/filename.csv';
ERROR: invalid input syntax for integer: "Event..."

CONTEXT: COPY chessgames, line 1, column id: "Event,..."

My first thoughts are that I need to create a first column entitle
'column id' but there is no reference to the requirement for this in
the section of the manual COPY. SO what is required please?

Thanks,

--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 06:20 AM
Tom Lane
 
Posts: n/a
Default Re: convert text file to database

e-letter <inpost@gmail.com> writes:
> I tried to import the csv file using the command:


> chessmatches=# COPY chessgames FROM '/absolute/path/filename.csv';
> ERROR: invalid input syntax for integer: "Event..."


Umm ... you didn't tell it the data is in CSV. I think you need at
least the HEADER option too. See the COPY manual page:
http://www.postgresql.org/docs/8.3/static/sql-copy.html

regards, tom lane

--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:08 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com