Coordinate PGN to Algebraic PGN conversion

Sort:
noisome

I have coordinate notation-based PGN files that I want to convert to algebraic notation.  Does anyone know of a method without using a GUI interface to do it nor by hand?  Most PGN readers don't understand the coordinates.  Here is a primary example of a first move fail.

1. g1f3

This fails the PGN test *MOST* of the time.  They prefer 1. Nf3.

GNUchess reads the coordinate-based moves from the files, but will not resave into algebraic.  So I am looking for help with this.

Thanks!
 

MrEdCollins

Yes.  Scid vs. PC understands this notation.

Using Scid vs. PC, open your coordinate based pgn file.  Then drag the entire file to the clipboard and then click on TOOLS and then EXPORT ALL FILTER GAMES and then EXPORT FILTER TO PGN.

Tell it where you'd like to save the new file.

The program will then save it, and it will save in the more familiar algebraic notation.

AWEChess1

@SDET can this conversion be done in C?

MikeCrockett

Take a look at this tool.  It might be helpful.

https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/

noisome

Thanks all.  I have actually solved it using pgn-extract.  It came in useful to do a lot of extra work that I needed.

The work involved reducing the notation to a size constraint notation for storage.  

karthikeyan_402

how to convert chess notation to chess games

KayvanSylvan

I found this great online tool. http://marianogappa.github.io/ostinato-examples/convert

I’m using it to transcribe games I played in the Oculus VR game Chess Club. After the game, I can take pictures of the completed move list, which are all in Algebraic notation (i.e. 1. e2e4 e7e5 2. g1f3, etc.) and I can bring up the pictures and paste in the moves in the tool and get a PGN move list I can cut and paste into other tools.

chessatk

1. d2d4
2. d7d6
3. g1f3
4. g8f6
5. c2c4
6. c7c6
7. b1c3
8. g7g6
9. e2e4
10. b8d7
11. f1e2
12. f8g7
13. e4e5
14. d6e5
15. d4e5
16. f6g4
17. e5e6
18. f7e6
19. f3g5
20. g7c3
21. b2c3
22. d8a5
23. e2g4
24. a5c3
25. c1d2
26. c3e5
27. g4e2
28. e8g8
29. e1g1
30. d7f6
31. g5f3
32. e5c7
33. d2h6
34. f8d8
35. d1c1
36. f6g4
37. h6f4
38. c7a5
39. h2h3
40. g4f6
41. c1e3
42. f6h5
43. f4e5
44. h5f6
45. f1d1
46. c8d7
47. d1b1
48. b7b6
49. b1b2
50. c6c5
51. a2a3
52. d7c6
53. e5f6
54. e7f6
55. e3e6
56. g8f8
57. e6f6
58. f8g8
59. f3g5
60. c6e8
61. g5e6
62. e8f7
63. f6g7

aka-Karthick

import chess.pgn

BATCH_SIZE = 5000

def process_game(game, output_file):
fen = game.headers.get("FEN", chess.STARTING_FEN)
fen_parts = fen.split(' ')
if len(fen_parts) != 6:
print(f"Skipping game with invalid FEN: {fen}")
return

board = chess.Board(fen)
san_moves = []

for move in game.mainline_moves():
san_moves.append(board.san(move))
board.push(move)

output_file.write(f"[Event \"{game.headers['Event']}\"]\n")
output_file.write(f"[Site \"{game.headers['Site']}\"]\n")
output_file.write(f"[FEN \"{fen}\"]\n")

output_file.write('\n'.join(san_moves))
output_file.write(" { * Result: " + game.headers["Result"] + " }\n\n")

def process_games_in_batch(pgn_file_path, output_file_prefix):
batch_count = 1
output_file = None

with open(pgn_file_path, 'r') as pgn_file:
while True:
output_file_path = f"{output_file_prefix}_{batch_count}.pgn"
output_file = open(output_file_path, 'w')

games_processed = 0
while games_processed < BATCH_SIZE:
game = chess.pgn.read_game(pgn_file)
if game is None:
break
process_game(game, output_file)
games_processed += 1

output_file.close()
batch_count += 1
if games_processed < BATCH_SIZE:
break

if __name__ == "__main__":
process_games_in_batch("input.pgn", "output_batch")