Skip to main content

Transforms a chess pgn file into a csv dataset containing game information and move information

Project description

pgn2data library

A library that converts a chess pgn files into tabulated data sets.

A pgn file can contain one or multiple chess games. The library parses the pgn file and creates two csv files:

  • Games file: contains high level information (e.g. date, site, event, score, players etc...)

  • Moves file: contains the moves for each game (e.g. notation, squares, fen position, is in check etc...)

The two files can be mapped together using a GUID which the process inserts into both files.

Implementation

Here is a basic example of how to convert a PGN file:

import PGNData

pgn_data = PGNData("data/pgn/tal_bronstein_1982.pgn")
result = pgn_data.export()
result.print_summary()

The Result object is a return value from the process, which allows you to check whether the dataset creation was successful.

To group multiple files into the same output file you can do the following:

pgn_data = PGNData(["data/pgn/file1.pgn","data/pgn/file/file2.pgn"],"output")
result = pgn_data.export()
result.print_summary()

This process the two pgn files in the specified list and exports them to file called "output.csv".

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgn2data-0.0.1.tar.gz (10.9 kB view details)

Uploaded Source

File details

Details for the file pgn2data-0.0.1.tar.gz.

File metadata

  • Download URL: pgn2data-0.0.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for pgn2data-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8a97ac97579fc1fc0aa2f95f629e9d99bf27605237338c25d2fe08230a6be644
MD5 e73e1fad115cffef49a7f902898ab1e4
BLAKE2b-256 c4bb1b05b09d05c870857537c80309dc796a6b59ab5125dc128959cc5ec1a7fa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page