Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Import a PGN file or string as an association of structured chess data
ResourceFunction["ImportPGN"]["input"] imports Portable Game Notation (PGN) from a file or string and outputs a list of associations of structured chess data. |
Start with a PGN text string:
| In[1]:= | ![]() |
Import this string as structured chess game data:
| In[2]:= |
| Out[2]= | ![]() |
Write the previous PGN out to a file:
| In[3]:= |
| Out[3]= |
| In[4]:= |
Import structured chess data directly from the created file:
| In[5]:= |
| Out[5]= | ![]() |
If "input" does not contain any properly formatted PGN games, ImportPGN["input"] returns {}:
| In[6]:= |
| Out[6]= |
The concatenation of one or more PGN game strings yields a list of game data associations, which are each assigned consecutive integer "GameNumber" keys:
| In[7]:= | ![]() |
| Out[7]= | ![]() |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License