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.2.tar.gz (11.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: pgn2data-0.0.2.tar.gz
  • Upload date:
  • Size: 11.0 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.2.tar.gz
Algorithm Hash digest
SHA256 5f0fff1569011268a774e3eb54d840385a1e20ae017f6393774b30d346e8d367
MD5 b6ea57e9cf967072d184a07b0bd12553
BLAKE2b-256 36a49c5b9f84f144ee171cbdca57c22721c9e6ebe66062e080722df72a4fefba

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