Transforms a chess pgn file into a csv dataset containing game information and move information
Project description
pgn2data library
A library that converts 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.
Installation
Run the following command on the python terminal:
pip install pgn2data
Implementation
Here is a basic example of how to convert a PGN file:
from converter.pgn_data import PGNData
pgn_data = PGNData("tal_bronstein_1982.pgn")
result = pgn_data.export()
result.print_summary()
The return value from the process allows you to check whether the datasets have been created or not.
To group multiple files into the same output file you can do the following:
pgn_data = PGNData(["file1.pgn","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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pgn2data-0.0.4.tar.gz
.
File metadata
- Download URL: pgn2data-0.0.4.tar.gz
- Upload date:
- Size: 12.3 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f560b46154dcb68e278ddff15e312bdd84c4c002a98b3420e991041ea7b511e |
|
MD5 | 93b8bc8e0ffdc017f87f6b161fd3a8bd |
|
BLAKE2b-256 | 4b76438e2778c1dcd86594a076cd290a6fe1cfd0a9a88040be0116d832189084 |