convert text file to database

From: e-letter <inpost(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: convert text file to database
Date: 2008-04-13 06:58:31
Message-ID: 298a6f60804122358k1f7c034ev8115f7dbe3f78531@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Readers,

I play chess and occasionally (i.e. when I win!) I save the moves to a
text file, of the following format:

[Event "Online Game"]
[Site "www.flyordie.com"]
[Date "yyyy.mm.dd"]
[Round "1"]
[White "player1"]
[Black "player2"]
[Result "1-0"]
[Termination "time forfeit"]
[UTCDate "yyyy.mm.dd"]
[TimeControl "1200"]

1. c4 e5 2. d4 Nc6...8. Bg5
1-0

and:

[Event "Online Game"]
[Site "www.flyordie.com"]
[Date "yyyy.mm.dd"]
[Round "1"]
[White "player1"]
[Black "player2"]
[Result "1-0"]
[Termination "normal"]
[UTCDate "yyyy.mm.dd"]
[TimeControl "1200"]

1. c4 e5 2. d4 f6 3. dxe5...25. Qd8# 1-0

There are various other termination options such as 'abandoned',
'draw', etc. My text file, now numbering about 4000 lines consists of
each game saved in this format, each game separated by a carriage
return.

Presumeably I would have to edit the text file to create fields
separated via commas?

I guess I could create a database 'chess games' with a table for each
field: event; site; date; termination; etc., correct?

What about the moves? Should I create a table column called 'moves',
in which case how to ensure data is placed in this database column? I
would also like to perform searches such as: "find me all games played
during the month of January"; or "show me the game with the fewest
number of moves"; or "how many games have I won via time forfeit?".

Yours,

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Shane Ambler 2008-04-13 11:20:36 Re: convert text file to database
Previous Message Frank Bax 2008-04-13 04:25:16 Re: problem with 8.1: createdb: could not connect to database postgres: could not connect to server: No such file or directory