A small python script that converts chess databases
stored in the .cbh file format to .pgn. The tool is currently very limited:
- converts only standard games - no
Chess960 - only the moves (including variations) of a game plus the following meta-info is converted:
- Event
- Site
- Date
- Round (plus subround if exists)
- White player name
- Black player name
- Result
- White Elo
- Black Elo
- in particular, as of now, no game annotations are converted
As python is quite slow, I recommend using pypy instead of cpython.
Even with pypy, a database with 9 million games takes approximately 8 hours to convert.
For comparison (reading and writing from/to SSD):
- with
pypy300 to 400 games per second (after a few seconds, when JIT kicks in) - with
cpython20 to 60 games per second
Install python, pypy, pip, and python-chess:
sudo apt install pypy3sudo apt install python3-pippypy3 -mpip install -U pip wheelpypy3 -mpip install python-chess
Download cbh2pgn here
and unzip to myfolder, then
cd myfolderpypy3 cbh2pgn.py -i your_database.cbh -o output.pgn
This will create output.pgn
Note that this will be too slow for large databases.
Install python, pip, and python-chess:
sudo apt install python3sudo apt install python3-pippip3 install python-chess
Download cbh2pgn here
and unzip to myfolder, then
cd myfolderpython3 cbh2pgn.py -i your_database.cbh -o output.pgn
This will create output.pgn
Copyright (c) 2022 Dominik Klein. Licensed under MIT (see file LICENSE)