Retrieving move information from a pgn file in Python

How can I extract move information from a pgn file in Python? I am new to programming and any help would be appreciated.

+5
source share
3 answers

I don’t have a PGN parser for python, but you can get the source code of the PGN parser for Xcode from in this place , this may be useful

+2
source

Try pgnparser .

Code example:

import pgn
import sys

f = open(sys.argv[1])
pgn_text = f.read()
f.close()
games = pgn.loads(pgn_text)
for game in games:
    print game.moves
+2
source

- Python , PGN java, . Miku , .pgn, .

  • .pgn , (1.e4 1. e4), , , , .

  • , . 5 , 0-0-0 ( ), Nge2 + ( g e2 (+)/checkmate (#)), Rexb5 (Rook on e b5).

  • 7 ( AND ). - 2 ( ).

  • . , , , .

  • The details given at the beginning (ELO ratings, location, etc.) vary from file to file.

+1
source

All Articles