Skip to content

Getting ChildNode value??? #1144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
oayk23 opened this issue Apr 9, 2025 · 0 comments
Open

Getting ChildNode value??? #1144

oayk23 opened this issue Apr 9, 2025 · 0 comments

Comments

@oayk23
Copy link

oayk23 commented Apr 9, 2025

Hello, i have a .pgn file which includes moves with comments. I want to extract the moves and the comments in the pgn games.
for example:
(some headers)
[event..]....

1.e4{this may leads to italian} e5 2.{ some comments... etc.}

i want to extract: "1.e4{this may leads to italian} e5 2.{ some comments... etc.}" this part.

following code:

pg = open("ChessAdmin annotated games.pgn")
game_list = []
while True:
    game = pgn.read_game(pg)
    if game is None:
        break
    mainline = game.game()
    for move in mainline:
        game_list.append(move)
        

leads something like this:

[<ChildNode at 0x1b931a4b590 (1. e4 ...)>,
 <ChildNode at 0x1b9377ad430 (1. c4 ...)>,
 <ChildNode at 0x1b9377af410 (1. c4 ...)>,
 <ChildNode at 0x1b9377bfe00 (1. d4 ...)>,
 <ChildNode at 0x1b9377afc20 (1. c4 ...)>,
 <ChildNode at 0x1b93784a6f0 (1. d4 ...)>,
 <ChildNode at 0x1b9377bce00 (1. c4 ...)>,
 <ChildNode at 0x1b93784e870 (1. c4 ...)>,
 <ChildNode at 0x1b93786b770 (1. e4 ...)>,
 <ChildNode at 0x1b93786ae40 (1. c4 ...)>,
 <ChildNode at 0x1b9377ade20 (1. e4 ...)>,
 <ChildNode at 0x1b93787b9e0 (1. c4 ...)>,
 <ChildNode at 0x1b93797d7f0 (1. c4 ...)>,
 <ChildNode at 0x1b937980ef0 (1. c4 ...)>,
 <ChildNode at 0x1b937986ba0 (1. c4 ...)>,

When i printing this move in for move in mainline: i get the desired output. but i want to extract it programmatically and save it to my database.
How can i do this? Could you help me with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant