- Import supports PGN notation.
- MIME Type: application/vnd.chess-pgn
- Standard text format for storing recorded chess games, supported by every major chess platform.
- PGN is an acronym for Portable Game Notation.
- ASCII format.
- Can store arbitrary game metadata.
- Can store annotations and suggested variations for any move.
- Standardized by Steven J. Edwards in 1994.
Import & Export
- Import["file.pgn"] imports a PGN file, returning a list of games and their metadata.
- Import["file.pgn",elements] imports the specified elements.
- See the following reference pages for full general information:
Import import from a file CloudImport import from a cloud object ImportString import from a string ImportByteArray import from a byte array
- General Import elements:
"Elements" list of elements and options available in this file "Rules" full list of rules for each element and option "Summary" a summary of the file
- Game elements:
"FENStrings" a list of FEN strings for each game "Games" a list of game moves and metadata "DynamicGameSummary" an interactive summary of the game "PositionRenderingList" a dynamic rendering for each game "Metadata" a list of game metadata "MoveCount" number of moves per game "Moves" a list of moves per game "GameResult" final game result per game
- Each move is a single move of one player, also known as a ply.
- Import by default uses the "Games" element for the PGN format.
- Game results could be "1-0", "0-1", "1/2-1/2" (draw) or "*" (unknown).
- Annotation element:
"AnnotatedMoves" move annotations as well as suggested move variations
- Overall file element:
"GameCount" number of games stored in the file
- Elements that involve rendering a chessboard take the following options:
"BoardOrientation" Automatic on which side of the board to place white pieces "Icons" Automatic a set of icons to use for chess pieces "SquareColors" Automatic a list of two colors for light and dark squares
- Elements that return chess moves take the following options:
"IncludeAnnotations" Automatic whether to include move annotations "IncludeVariations" Automatic whether to include move variations
Examplesopen allclose all
List available Import elements:
Import Elements (19)
Import last 5 positions from the first game in the file as Graphics:
Import Options (14)
By default, Import displays white pieces at the bottom: