Skip to main content
File added late

1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.

A simple python PGN parser.

PGN (Portable Game Notation) is computer-processible format for recording chess games, both the moves and related data.

This module is based on features of others python parser modules (such json and yaml). The basic usage:

import pgn

pgn_text = open('morphy.pgn).read()
pgn_game = pgn.PGNGame()

print pgn.loads(pgn_text) # Returns a list of PGNGame
print pgn.dumps(pgn_game) # Returns a string with a pgn game

Features:

  • Required tags: “Event”, “Site”, “Date”, “Round”, “White”, “Black”, and “Result”.

  • Optional tags: “Annotator”, “PlyCount”, “TimeControl”, “Time”, “Termination”, “Mode”, and “FEN”.

  • Commentaries: “;” (a comment that continues to the end of the line) and “{” (which continues until a matching “}”). The last one just in moves list.

PGN example:

[Event "F/S Return Match"]
[Site "Belgrade, Serbia Yugoslavia|JUG"]
[Date "1992.11.04"]
[Round "29"]
[White "Fischer, Robert J."]
[Black "Spassky, Boris V."]
[Result "1/2-1/2"]

1. e4 e5 2. Nf3 Nc6 3. Bb5 {This opening is called the Ruy Lopez.} 3... a6
4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Nb8  10. d4 Nbd7
11. c4 c6 12. cxb5 axb5 13. Nc3 Bb7 14. Bg5 b4 15. Nb1 h6 16. Bh4 c5 17. dxe5
Nxe4 18. Bxe7 Qxe7 19. exd6 Qf6 20. Nbd2 Nxd6 21. Nc4 Nxc4 22. Bxc4 Nb6
23. Ne5 Rae8 24. Bxf7+ Rxf7 25. Nxf7 Rxe1+ 26. Qxe1 Kxf7 27. Qe3 Qg5 28. Qxg5
hxg5 29. b3 Ke6 30. a3 Kd6 31. axb4 cxb4 32. Ra5 Nd5 33. f3 Bc8 34. Kf2 Bf5
35. Ra7 g6 36. Ra6+ Kc5 37. Ke1 Nf4 38. g3 Nxh3 39. Kd2 Kb5 40. Rd6 Kc5 41. Ra6
Nf2 42. g4 Bd3 43. Re6 1/2-1/2

Metadata

Release files for pgnparser 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

File added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distribution (sdist)

Source distribution for pgnparser 1.0
File Size Uploaded
pgnparser-1.0.zip 7.3 kB Details

Release files / pgnparser-1.0.zip

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL pgnparser-1.0.zip
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1d70e665bf4702fc8bb1f087515ad104df1d0e6008e2459325f6486b7bd33911
BLAKE2b-256 checksum
How to use checksums
ef70427a456b842325c8e59bea2c41d724ad297824e17431efeaa1074fd330bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page