Dos someone know how it's possible to delete the moves after the name of the opening in this pgn exemple. I want to cut the games that way for training purposes. Also some way to remove these { [%evp 21,27,9,13,6,6,6,14,14] } annotations.
I want to delete all the moves after for exemple '{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) }'. I also want to delete all other text comments like the %evp end the %cal. I only want to keep the annotation with the eco code and the name of the opening.
Maybe it can be done with some advanced search and replace options in a text editor like Sublime Text or Ultra Edit?
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A90"]
{ [%evp 15,27,15,26,26,32,11,11,8,10,7,17,17,17,16] } 1.d4 d5 2.c4 e6 3.Nf3
c6 4.Nbd2 { [%cal Bb1d2,Bd2f3,Bf3e5][%mdl 32] } 4...f5 5.g3 Nf6 6.Bg2 Bd6
7.O-O O-O 8.Ne5 b6 9.Ndf3
{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) } (
9.Qc2 Bb7 10.cxd5 cxd5 11.Ndf3 Ne4 12.h4 Nd7 13.Bf4 Ndf6 14.Rac1 Ba6 15.Rfe1
Ng4 16.Qa4 Bb7
{ 1/2-1/2 (26) Dubov,D (2703)-Carlsen,M (2835) St Petersburg 2018 } ) 9...Ne4
10.a4 $146 ( { Predecessor: } 10.Bf4 Qe7 11.Rc1 Bb7 12.Nd3 Bxf4 13.gxf4 Nd7
14.Nfe5 Nxe5 15.Nxe5 c5 16.cxd5 Bxd5 17.dxc5 bxc5
{ 1/2-1/2 (31) Yilmaz,M (2619)-Adhiban,B (2650) Reykjavik 2018 } ) 10...Bb7
{ The position is equal. } 11.cxd5 cxd5 12.Be3 Nc6 13.Nxc6 Bxc6 14.Ne5 *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
{ [%evp 21,27,9,13,6,6,6,14,14] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O
d6 6.c4 O-O 7.Nc3 c6 8.d5 e5 9.dxe6 Bxe6 10.b3 Na6 11.Ng5 Qe7
{ The position is equal. } 12.Nxe6
{ A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 }
12...Qxe6 13.Bb2 Rad8 14.Qc2 { Predecessor: } 14...Rfe8 $146 15.Rad1 Nc5
16.e3 Rd7 17.b4 Nce4 18.Nxe4 Nxe4 19.Bxg7 Kxg7 20.Rd4 Nf6 21.Rfd1 a6 22.a4
Qe5 23.b5 axb5 24.cxb5 cxb5 25.axb5 Qxb5 26.Rxd6 Rxd6 27.Rxd6
{ 1/2-1/2 (130) Prohaszka,P (2596)-Gasanov,E (2484) Zalakaros 2017 } *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A87"]
{ [%evp 19,27,37,39,38,41,34,59,65,65,65] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2
Nf6 5.O-O d6 6.c4 O-O 7.Nc3 Qe8 8.Re1 Qf7 9.b3 Ne4 10.Bb2 Nc6
{ White is slightly better. } 11.Rc1
{ [%emt 0:00:05] A87: Dutch Defence: Leningrad System: Nf3 } 11...h6 (
11...e5 12.d5 Nb4 13.a3 Nxc3 14.Rxc3 Na6 15.b4 e4 16.Nd4 Bd7 17.f3 c5 18.dxc6
bxc6 19.fxe4 fxe4
{ 0-1 (40) Eljanov,P (2663)-Gurevich,M (2652) Khanty-Mansiysk 2005 } ) 12.d5
Ne5 13.Nxe5 Bxe5 14.f4 { Predecessor: } 14...Bg7 $146 15.Qc2 Nxc3 16.Bxc3 Bd7
17.e4 Bxc3 18.Qxc3 fxe4 19.Rxe4
{ 1-0 (50) Carlsen, M (2450)-Potapov,P (2267) Chalkidiki 2003 } *
So I want it to look like this.
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A90"]
1.d4 d5 2.c4 e6 3.Nf3 c6 4.Nbd2 f5 5.g3 Nf6 6.Bg2 Bd6 7.O-O O-O 8.Ne5 b6 9.Ndf3
{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) }
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O d6 6.c4 O-O 7.Nc3 c6 8.d5 e5 9.dxe6 Bxe6 10.b3 Na6 11.Ng5 Qe7 12.Nxe6
{ A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 }
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A87"]
1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O d6 6.c4 O-O 7.Nc3 Qe8 8.Re1 Qf7 9.b3 Ne4 10.Bb2 Nc6 11.Rc1
{ A87: Dutch Defence: Leningrad System: Nf3 }
Or if that's not possible this would also be ok.
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A90"]
{ [%evp 15,27,15,26,26,32,11,11,8,10,7,17,17,17,16] } 1.d4 d5 2.c4 e6 3.Nf3
c6 4.Nbd2 { [%cal Bb1d2,Bd2f3,Bf3e5][%mdl 32] } 4...f5 5.g3 Nf6 6.Bg2 Bd6
7.O-O O-O 8.Ne5 b6 9.Ndf3
{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) }
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
{ [%evp 21,27,9,13,6,6,6,14,14] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O
d6 6.c4 O-O 7.Nc3 c6 8.d5 e5 9.dxe6 Bxe6 10.b3 Na6 11.Ng5 Qe7
{ The position is equal. } 12.Nxe6
{ A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 }
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A87"]
{ [%evp 19,27,37,39,38,41,34,59,65,65,65] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2
Nf6 5.O-O d6 6.c4 O-O 7.Nc3 Qe8 8.Re1 Qf7 9.b3 Ne4 10.Bb2 Nc6
{ White is slightly better. } 11.Rc1
{ [%emt 0:00:05] A87: Dutch Defence: Leningrad System: Nf3 }
How to cut these pgn games.
Moderators: hgm, Rebel, chrisw
-
- Posts: 239
- Joined: Fri Jul 06, 2018 4:23 pm
- Full name: Jonathan Cremers
-
- Posts: 12542
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: How to cut these pgn games.
You need a trailing asterisk in the PGN body text after trimming.
Seems like you are simply looking for a named opening db.
Maybe you want something like this:
https://drive.google.com/open?id=1LZsVP ... U_-jZvxINR
Seems like you are simply looking for a named opening db.
Maybe you want something like this:
https://drive.google.com/open?id=1LZsVP ... U_-jZvxINR
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
-
- Posts: 229
- Joined: Thu Mar 10, 2016 6:17 pm
- Location: Canada
Re: How to cut these pgn games.
pgn-extract and/or Norm Pollock's executables will do it for you.Jonathan003 wrote: ↑Thu Mar 14, 2019 5:02 pm Dos someone know how it's possible to delete the moves after the name of the opening in this pgn exemple. I want to cut the games that way for training purposes. Also some way to remove these { [%evp 21,27,9,13,6,6,6,14,14] } annotations.
I want to delete all the moves after for exemple '{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) }'. I also want to delete all other text comments like the %evp end the %cal. I only want to keep the annotation with the eco code and the name of the opening.
Maybe it can be done with some advanced search and replace options in a text editor like Sublime Text or Ultra Edit?
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A90"]
{ [%evp 15,27,15,26,26,32,11,11,8,10,7,17,17,17,16] } 1.d4 d5 2.c4 e6 3.Nf3
c6 4.Nbd2 { [%cal Bb1d2,Bd2f3,Bf3e5][%mdl 32] } 4...f5 5.g3 Nf6 6.Bg2 Bd6
7.O-O O-O 8.Ne5 b6 9.Ndf3
{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) } (
9.Qc2 Bb7 10.cxd5 cxd5 11.Ndf3 Ne4 12.h4 Nd7 13.Bf4 Ndf6 14.Rac1 Ba6 15.Rfe1
Ng4 16.Qa4 Bb7
{ 1/2-1/2 (26) Dubov,D (2703)-Carlsen,M (2835) St Petersburg 2018 } ) 9...Ne4
10.a4 $146 ( { Predecessor: } 10.Bf4 Qe7 11.Rc1 Bb7 12.Nd3 Bxf4 13.gxf4 Nd7
14.Nfe5 Nxe5 15.Nxe5 c5 16.cxd5 Bxd5 17.dxc5 bxc5
{ 1/2-1/2 (31) Yilmaz,M (2619)-Adhiban,B (2650) Reykjavik 2018 } ) 10...Bb7
{ The position is equal. } 11.cxd5 cxd5 12.Be3 Nc6 13.Nxc6 Bxc6 14.Ne5 *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
{ [%evp 21,27,9,13,6,6,6,14,14] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O
d6 6.c4 O-O 7.Nc3 c6 8.d5 e5 9.dxe6 Bxe6 10.b3 Na6 11.Ng5 Qe7
{ The position is equal. } 12.Nxe6
{ A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 }
12...Qxe6 13.Bb2 Rad8 14.Qc2 { Predecessor: } 14...Rfe8 $146 15.Rad1 Nc5
16.e3 Rd7 17.b4 Nce4 18.Nxe4 Nxe4 19.Bxg7 Kxg7 20.Rd4 Nf6 21.Rfd1 a6 22.a4
Qe5 23.b5 axb5 24.cxb5 cxb5 25.axb5 Qxb5 26.Rxd6 Rxd6 27.Rxd6
{ 1/2-1/2 (130) Prohaszka,P (2596)-Gasanov,E (2484) Zalakaros 2017 } *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A87"]
{ [%evp 19,27,37,39,38,41,34,59,65,65,65] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2
Nf6 5.O-O d6 6.c4 O-O 7.Nc3 Qe8 8.Re1 Qf7 9.b3 Ne4 10.Bb2 Nc6
{ White is slightly better. } 11.Rc1
{ [%emt 0:00:05] A87: Dutch Defence: Leningrad System: Nf3 } 11...h6 (
11...e5 12.d5 Nb4 13.a3 Nxc3 14.Rxc3 Na6 15.b4 e4 16.Nd4 Bd7 17.f3 c5 18.dxc6
bxc6 19.fxe4 fxe4
{ 0-1 (40) Eljanov,P (2663)-Gurevich,M (2652) Khanty-Mansiysk 2005 } ) 12.d5
Ne5 13.Nxe5 Bxe5 14.f4 { Predecessor: } 14...Bg7 $146 15.Qc2 Nxc3 16.Bxc3 Bd7
17.e4 Bxc3 18.Qxc3 fxe4 19.Rxe4
{ 1-0 (50) Carlsen, M (2450)-Potapov,P (2267) Chalkidiki 2003 } *
So I want it to look like this.
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A90"]
1.d4 d5 2.c4 e6 3.Nf3 c6 4.Nbd2 f5 5.g3 Nf6 6.Bg2 Bd6 7.O-O O-O 8.Ne5 b6 9.Ndf3
{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) }
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O d6 6.c4 O-O 7.Nc3 c6 8.d5 e5 9.dxe6 Bxe6 10.b3 Na6 11.Ng5 Qe7 12.Nxe6
{ A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 }
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A87"]
1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O d6 6.c4 O-O 7.Nc3 Qe8 8.Re1 Qf7 9.b3 Ne4 10.Bb2 Nc6 11.Rc1
{ A87: Dutch Defence: Leningrad System: Nf3 }
Or if that's not possible this would also be ok.
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A90"]
{ [%evp 15,27,15,26,26,32,11,11,8,10,7,17,17,17,16] } 1.d4 d5 2.c4 e6 3.Nf3
c6 4.Nbd2 { [%cal Bb1d2,Bd2f3,Bf3e5][%mdl 32] } 4...f5 5.g3 Nf6 6.Bg2 Bd6
7.O-O O-O 8.Ne5 b6 9.Ndf3
{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) }
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
{ [%evp 21,27,9,13,6,6,6,14,14] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O
d6 6.c4 O-O 7.Nc3 c6 8.d5 e5 9.dxe6 Bxe6 10.b3 Na6 11.Ng5 Qe7
{ The position is equal. } 12.Nxe6
{ A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 }
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A87"]
{ [%evp 19,27,37,39,38,41,34,59,65,65,65] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2
Nf6 5.O-O d6 6.c4 O-O 7.Nc3 Qe8 8.Re1 Qf7 9.b3 Ne4 10.Bb2 Nc6
{ White is slightly better. } 11.Rc1
{ [%emt 0:00:05] A87: Dutch Defence: Leningrad System: Nf3 }
-
- Posts: 239
- Joined: Fri Jul 06, 2018 4:23 pm
- Full name: Jonathan Cremers
Re: How to cut these pgn games.
I have booth pgn-extract and/or Norm Pollock's executables but I don't have a lot of experience with it.
I find a way to remove these '{ [%cal Bb1d2,Bd2f3,Bf3e5][%mdl 32]' characters with fenRemove included in Norm Pollock's executables.
I still look for ways to remove these '{ [%evp 15,27,15,26,26,32,11,11,8,10,7,17,17,17,16] }', '[%emt 0:00: 05, and other annotations beside the eco code and opening name. I think I'm going to have to do it manually.
If all annotations where removed except the annotation with the eco code and the opening name, than I could replace } with }*
That would cut the games. But it doesn't work if there are still annotations like { White is slightly better. }, before the annotation with the eco code and opening name.
I find a way to remove these '{ [%cal Bb1d2,Bd2f3,Bf3e5][%mdl 32]' characters with fenRemove included in Norm Pollock's executables.
I still look for ways to remove these '{ [%evp 15,27,15,26,26,32,11,11,8,10,7,17,17,17,16] }', '[%emt 0:00: 05, and other annotations beside the eco code and opening name. I think I'm going to have to do it manually.
If all annotations where removed except the annotation with the eco code and the opening name, than I could replace } with }*
That would cut the games. But it doesn't work if there are still annotations like { White is slightly better. }, before the annotation with the eco code and opening name.
-
- Posts: 239
- Joined: Fri Jul 06, 2018 4:23 pm
- Full name: Jonathan Cremers
Re: How to cut these pgn games.
Alternatively does someone know how to automatically annotate a big pgn file with many games so the games looks like this:
[Event "Example PGN Chess Game Record"]
[Site "Moscow"]
[Date "2003.12.25"]
[Round "2"]
[White "Blaganov"]
[Black "Dufus"]
[Result "1-0"]
[Opening "Scandinavian"]
[ECO "B01"]
1.e4 d5 2.exd5 Qxd5 3.Nc3 Qd8 4.d4 Nf6
{B01 Scandinavian}
5.Bc4 c6 6.Nf3 Bg4 7.Bxf7 Kxf7 8.Ne5 Kg8
9.Nxg4 Nbd7 10.Qe2 Nxg4 11.Qe6# 0-1
Or even better look someting like this. With a more detailed opening name, and with the annotation later in the game.
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O d6 6.c4 O-O 7.Nc3 c6 8.d5 e5 9.dxe6 Bxe6 10.b3 Na6 11.Ng5 Qe7 12.Nxe6
{ A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 }
You know what I mean. With only one annotation in the game. The annotation with the eco code and the opening name. Without having to type this annotations manually.
[Event "Example PGN Chess Game Record"]
[Site "Moscow"]
[Date "2003.12.25"]
[Round "2"]
[White "Blaganov"]
[Black "Dufus"]
[Result "1-0"]
[Opening "Scandinavian"]
[ECO "B01"]
1.e4 d5 2.exd5 Qxd5 3.Nc3 Qd8 4.d4 Nf6
{B01 Scandinavian}
5.Bc4 c6 6.Nf3 Bg4 7.Bxf7 Kxf7 8.Ne5 Kg8
9.Nxg4 Nbd7 10.Qe2 Nxg4 11.Qe6# 0-1
Or even better look someting like this. With a more detailed opening name, and with the annotation later in the game.
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O d6 6.c4 O-O 7.Nc3 c6 8.d5 e5 9.dxe6 Bxe6 10.b3 Na6 11.Ng5 Qe7 12.Nxe6
{ A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 }
You know what I mean. With only one annotation in the game. The annotation with the eco code and the opening name. Without having to type this annotations manually.
-
- Posts: 4889
- Joined: Thu Mar 09, 2006 6:34 am
- Location: Pen Argyl, Pennsylvania
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: How to cut these pgn games.
Creating a script to process this desired output.Jonathan003 wrote: ↑Thu Mar 14, 2019 5:02 pm Dos someone know how it's possible to delete the moves after the name of the opening in this pgn exemple. I want to cut the games that way for training purposes. Also some way to remove these { [%evp 21,27,9,13,6,6,6,14,14] } annotations.
I want to delete all the moves after for exemple '{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) }'. I also want to delete all other text comments like the %evp end the %cal. I only want to keep the annotation with the eco code and the name of the opening.
Maybe it can be done with some advanced search and replace options in a text editor like Sublime Text or Ultra Edit?
Prepare to install python 3 https://www.python.org/downloads/
and python-chess https://www.python.org/downloads/
After installation of python 3, install python-chess with command from console on windows
pip install python-chess.
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: How to cut these pgn games.
pgn-extract can remove comments, problem is not all comments are to be removed.MikeB wrote: ↑Fri Mar 15, 2019 2:48 am get pgn extract...it does it all...
https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/
pgn-extract can cut length at specified plies, problem is his pgn has variable length depends on where the comment with ECO is located.
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: How to cut these pgn games.
input: my_games.pgn
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A90"]
{ [%evp 15,27,15,26,26,32,11,11,8,10,7,17,17,17,16] } 1.d4 d5 2.c4 e6 3.Nf3
c6 4.Nbd2 { [%cal Bb1d2,Bd2f3,Bf3e5][%mdl 32] } 4...f5 5.g3 Nf6 6.Bg2 Bd6
7.O-O O-O 8.Ne5 b6 9.Ndf3
{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) } (
9.Qc2 Bb7 10.cxd5 cxd5 11.Ndf3 Ne4 12.h4 Nd7 13.Bf4 Ndf6 14.Rac1 Ba6 15.Rfe1
Ng4 16.Qa4 Bb7
{ 1/2-1/2 (26) Dubov,D (2703)-Carlsen,M (2835) St Petersburg 2018 } ) 9...Ne4
10.a4 $146 ( { Predecessor: } 10.Bf4 Qe7 11.Rc1 Bb7 12.Nd3 Bxf4 13.gxf4 Nd7
14.Nfe5 Nxe5 15.Nxe5 c5 16.cxd5 Bxd5 17.dxc5 bxc5
{ 1/2-1/2 (31) Yilmaz,M (2619)-Adhiban,B (2650) Reykjavik 2018 } ) 10...Bb7
{ The position is equal. } 11.cxd5 cxd5 12.Be3 Nc6 13.Nxc6 Bxc6 14.Ne5 *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
{ [%evp 21,27,9,13,6,6,6,14,14] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O
d6 6.c4 O-O 7.Nc3 c6 8.d5 e5 9.dxe6 Bxe6 10.b3 Na6 11.Ng5 Qe7
{ The position is equal. } 12.Nxe6
{ A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 }
12...Qxe6 13.Bb2 Rad8 14.Qc2 { Predecessor: } 14...Rfe8 $146 15.Rad1 Nc5
16.e3 Rd7 17.b4 Nce4 18.Nxe4 Nxe4 19.Bxg7 Kxg7 20.Rd4 Nf6 21.Rfd1 a6 22.a4
Qe5 23.b5 axb5 24.cxb5 cxb5 25.axb5 Qxb5 26.Rxd6 Rxd6 27.Rxd6
{ 1/2-1/2 (130) Prohaszka,P (2596)-Gasanov,E (2484) Zalakaros 2017 } *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A87"]
{ [%evp 19,27,37,39,38,41,34,59,65,65,65] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2
Nf6 5.O-O d6 6.c4 O-O 7.Nc3 Qe8 8.Re1 Qf7 9.b3 Ne4 10.Bb2 Nc6
{ White is slightly better. } 11.Rc1
{ [%emt 0:00:05] A87: Dutch Defence: Leningrad System: Nf3 } 11...h6 (
11...e5 12.d5 Nb4 13.a3 Nxc3 14.Rxc3 Na6 15.b4 e4 16.Nd4 Bd7 17.f3 c5 18.dxc6
bxc6 19.fxe4 fxe4
{ 0-1 (40) Eljanov,P (2663)-Gurevich,M (2652) Khanty-Mansiysk 2005 } ) 12.d5
Ne5 13.Nxe5 Bxe5 14.f4 { Predecessor: } 14...Bg7 $146 15.Qc2 Nxc3 16.Bxc3 Bd7
17.e4 Bxc3 18.Qxc3 fxe4 19.Rxe4
{ 1-0 (50) Carlsen, M (2450)-Potapov,P (2267) Chalkidiki 2003 } *
output: output_mygames.pgn
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A90"]
1. d4 d5 2. c4 e6 3. Nf3 c6 4. Nbd2 f5 5. g3 Nf6 6. Bg2 Bd6 7. O-O O-O 8. Ne5 b6 9. Ndf3 { A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) } *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
1. d4 f5 2. Nf3 g6 3. g3 Bg7 4. Bg2 Nf6 5. O-O d6 6. c4 O-O 7. Nc3 c6 8. d5 e5 9. dxe6 Bxe6 10. b3 Na6 11. Ng5 Qe7 12. Nxe6 { A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 } *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A87"]
1. d4 f5 2. Nf3 g6 3. g3 Bg7 4. Bg2 Nf6 5. O-O d6 6. c4 O-O 7. Nc3 Qe8 8. Re1 Qf7 9. b3 Ne4 10. Bb2 Nc6 11. Rc1 { A87: Dutch Defence: Leningrad System: Nf3 } *
python script, pgn_modifier.py
Command line:
python pgn_modifier.py
your pgn file should be renamed to my_games.pgn
See the script code..
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A90"]
{ [%evp 15,27,15,26,26,32,11,11,8,10,7,17,17,17,16] } 1.d4 d5 2.c4 e6 3.Nf3
c6 4.Nbd2 { [%cal Bb1d2,Bd2f3,Bf3e5][%mdl 32] } 4...f5 5.g3 Nf6 6.Bg2 Bd6
7.O-O O-O 8.Ne5 b6 9.Ndf3
{ A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) } (
9.Qc2 Bb7 10.cxd5 cxd5 11.Ndf3 Ne4 12.h4 Nd7 13.Bf4 Ndf6 14.Rac1 Ba6 15.Rfe1
Ng4 16.Qa4 Bb7
{ 1/2-1/2 (26) Dubov,D (2703)-Carlsen,M (2835) St Petersburg 2018 } ) 9...Ne4
10.a4 $146 ( { Predecessor: } 10.Bf4 Qe7 11.Rc1 Bb7 12.Nd3 Bxf4 13.gxf4 Nd7
14.Nfe5 Nxe5 15.Nxe5 c5 16.cxd5 Bxd5 17.dxc5 bxc5
{ 1/2-1/2 (31) Yilmaz,M (2619)-Adhiban,B (2650) Reykjavik 2018 } ) 10...Bb7
{ The position is equal. } 11.cxd5 cxd5 12.Be3 Nc6 13.Nxc6 Bxc6 14.Ne5 *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
{ [%evp 21,27,9,13,6,6,6,14,14] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2 Nf6 5.O-O
d6 6.c4 O-O 7.Nc3 c6 8.d5 e5 9.dxe6 Bxe6 10.b3 Na6 11.Ng5 Qe7
{ The position is equal. } 12.Nxe6
{ A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 }
12...Qxe6 13.Bb2 Rad8 14.Qc2 { Predecessor: } 14...Rfe8 $146 15.Rad1 Nc5
16.e3 Rd7 17.b4 Nce4 18.Nxe4 Nxe4 19.Bxg7 Kxg7 20.Rd4 Nf6 21.Rfd1 a6 22.a4
Qe5 23.b5 axb5 24.cxb5 cxb5 25.axb5 Qxb5 26.Rxd6 Rxd6 27.Rxd6
{ 1/2-1/2 (130) Prohaszka,P (2596)-Gasanov,E (2484) Zalakaros 2017 } *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A87"]
{ [%evp 19,27,37,39,38,41,34,59,65,65,65] } 1.d4 f5 2.Nf3 g6 3.g3 Bg7 4.Bg2
Nf6 5.O-O d6 6.c4 O-O 7.Nc3 Qe8 8.Re1 Qf7 9.b3 Ne4 10.Bb2 Nc6
{ White is slightly better. } 11.Rc1
{ [%emt 0:00:05] A87: Dutch Defence: Leningrad System: Nf3 } 11...h6 (
11...e5 12.d5 Nb4 13.a3 Nxc3 14.Rxc3 Na6 15.b4 e4 16.Nd4 Bd7 17.f3 c5 18.dxc6
bxc6 19.fxe4 fxe4
{ 0-1 (40) Eljanov,P (2663)-Gurevich,M (2652) Khanty-Mansiysk 2005 } ) 12.d5
Ne5 13.Nxe5 Bxe5 14.f4 { Predecessor: } 14...Bg7 $146 15.Qc2 Nxc3 16.Bxc3 Bd7
17.e4 Bxc3 18.Qxc3 fxe4 19.Rxe4
{ 1-0 (50) Carlsen, M (2450)-Potapov,P (2267) Chalkidiki 2003 } *
output: output_mygames.pgn
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A90"]
1. d4 d5 2. c4 e6 3. Nf3 c6 4. Nbd2 f5 5. g3 Nf6 6. Bg2 Bd6 7. O-O O-O 8. Ne5 b6 9. Ndf3 { A90: Dutch Defence: Miscellaneous and Modern Stonewall (with ...Bd6) } *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A88"]
1. d4 f5 2. Nf3 g6 3. g3 Bg7 4. Bg2 Nf6 5. O-O d6 6. c4 O-O 7. Nc3 c6 8. d5 e5 9. dxe6 Bxe6 10. b3 Na6 11. Ng5 Qe7 12. Nxe6 { A88: Dutch Defence: Leningrad System: 5 Nf3 0-0 6 0-0 d6 7 Nc3 c6 } *
[Event "Chess Position Trainer"]
[Site "Chess Position Trainer"]
[Date "????.??.??"]
[Round "?"]
[White "My White Opening"]
[Black "Black Opening"]
[Result "*"]
[Annotator "Tactical Analysis 2.10 (6s)"]
[ECO "A87"]
1. d4 f5 2. Nf3 g6 3. g3 Bg7 4. Bg2 Nf6 5. O-O d6 6. c4 O-O 7. Nc3 Qe8 8. Re1 Qf7 9. b3 Ne4 10. Bb2 Nc6 11. Rc1 { A87: Dutch Defence: Leningrad System: Nf3 } *
python script, pgn_modifier.py
Code: Select all
"""
pgn_modifier.py
Read pgn and remove some comments and cut the move length at specific move.
Requirements:
python 3
python-chess v0.26.0
"""
import os
import chess.pgn
def main():
pgnfn = 'my_games.pgn'
output_pgnfn = 'output_mygames.pgn'
# Delete existing output_mygames.pgn
if os.path.isfile(output_pgnfn):
os.remove(output_pgnfn)
# Build ECO, used to cut the game length
ECO = []
for i in range(100):
# A00 to E99
aeco = 'A{:02d}'.format(i)
beco = 'B{:02d}'.format(i)
ceco = 'C{:02d}'.format(i)
deco = 'D{:02d}'.format(i)
eeco = 'E{:02d}'.format(i)
ECO.append(aeco)
ECO.append(beco)
ECO.append(ceco)
ECO.append(deco)
ECO.append(eeco)
gcnt = 0
# Parse games in pgn file
with open(pgnfn, 'r') as pgn:
game = chess.pgn.read_game(pgn)
while game:
gcnt += 1
# Console progress
print('game: {}'.format(gcnt))
mygame = chess.pgn.Game()
mynode = mygame
# Copy orig game header to our saved game header
for k, v in game.headers.items():
mygame.headers[k] = v
for node in game.mainline():
game_move = node.move
move_comment = node.comment
# Modify move comment, remove text before ECO
# [%emt 0:00:05] A87: Dutch Defence: Leningrad System: Nf3
if '[' in move_comment and ']' in move_comment:
move_comment = move_comment.split(']')[1].strip()
mynode = mynode.add_main_variation(game_move)
# Check the move comment where we can cut the game length
is_foundvalidcomment = False
for c in ECO:
if c in move_comment:
is_foundvalidcomment = True
break
if is_foundvalidcomment:
mynode.comment = move_comment
# Don't copy other moves we stop here
if is_foundvalidcomment:
break
# Print to output file
with open(output_pgnfn, 'a') as w:
w.write('{}\n\n'.format(mygame))
# Print to console
print(mygame)
print()
# Read another game
game = chess.pgn.read_game(pgn)
if __name__ == '__main__':
main()
python pgn_modifier.py
your pgn file should be renamed to my_games.pgn
See the script code..
Code: Select all
def main():
pgnfn = 'my_games.pgn'
-
- Posts: 239
- Joined: Fri Jul 06, 2018 4:23 pm
- Full name: Jonathan Cremers
Re: How to cut these pgn games.
Thanks Freddy. I will try it.
Can you please give me some guidance, I'm not familiar with this. I'm not a programmer or so.
I have download Phython 3.7.2 from the link you provided and installed it.
I couldn't find python-chess in the link you send. But I found python-chess 0.27.1 here: https://pypi.org/project/python-chess/#files
I downloaded
python_chess-0.27.1-py3-none-any.whl
and installed it from console on windows by typing: pip install python-chess.
What to do next please? Where can I find this 'pgn_modifier.py'
I see you posted some codes. I can select these and copy them but what to do next?
Sorry for my many questions but I want this to work.
Can you please give me some guidance, I'm not familiar with this. I'm not a programmer or so.
I have download Phython 3.7.2 from the link you provided and installed it.
I couldn't find python-chess in the link you send. But I found python-chess 0.27.1 here: https://pypi.org/project/python-chess/#files
I downloaded
python_chess-0.27.1-py3-none-any.whl
and installed it from console on windows by typing: pip install python-chess.
What to do next please? Where can I find this 'pgn_modifier.py'
I see you posted some codes. I can select these and copy them but what to do next?
Sorry for my many questions but I want this to work.