Tool to extract parts of games from pgn file

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

JohnS
Posts: 215
Joined: Sun Feb 24, 2008 2:08 am

Re: Tool to extract parts of games from pgn file

Post by JohnS »

Hi Ferdy

I have another suggestion for the tool.

Is it possible to output the player ratings as well? Perhaps it is safer to output all the pgn fields that are in the input file.

Thanks.
John
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Tool to extract parts of games from pgn file

Post by Ferdy »

JohnS wrote:Hi Ferdy

I have another suggestion for the tool.

Is it possible to output the player ratings as well? Perhaps it is safer to output all the pgn fields that are in the input file.

Thanks.
John
I will do that.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Tool to extract parts of games from pgn file

Post by Ferdy »

JohnS wrote:Hi Ferdy

I have another suggestion for the tool.

Is it possible to output the player ratings as well? Perhaps it is safer to output all the pgn fields that are in the input file.

Thanks.
John
Source was revised, but have not released yet the exe.
https://github.com/fsmosca/GameFragmentExtractor

If you have python and python-chess installed you can try it.

gfe.py -i <your input pgn file> -o <your output pgn file>

It works on my test.
JohnS
Posts: 215
Joined: Sun Feb 24, 2008 2:08 am

Re: Tool to extract parts of games from pgn file

Post by JohnS »

Thanks for the update Ferdy. I will test it when you upload the exe file since I don't have the support programs required.

John
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Tool to extract parts of games from pgn file

Post by Ferdy »

JohnS wrote:Thanks for the update Ferdy. I will test it when you upload the exe file since I don't have the support programs required.

John
Released 1.1
https://github.com/fsmosca/GameFragment ... r/releases
JohnS
Posts: 215
Joined: Sun Feb 24, 2008 2:08 am

Re: Tool to extract parts of games from pgn file

Post by JohnS »

Ferdy

Many thanks for the new version. It works great.

All the best.
John
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Tool to extract parts of games from pgn file

Post by Ferdy »

JohnS wrote:Ferdy

Many thanks for the new version. It works great.

All the best.
John
I am glad that it worked, since this is my first time handling the variations using python-chess modules :).
JohnS
Posts: 215
Joined: Sun Feb 24, 2008 2:08 am

Re: Tool to extract parts of games from pgn file

Post by JohnS »

Hi Ferdy

The following games cause problems and the tool doesn't work.

[Event "?"]
[Site "?"]
[Date "2017.05.01"]
[Round "?"]
[White "W"]
[Black "B"]
[Result "1-0"]
[ECO "B00"]
[PlyCount "5"]
[SourceDate "2017.05.01"]
[SourceVersionDate "2017.05.01"]

1. e4 g5 2. d4 f6 {[#] a blunder} 3. Qh5# 1-0

This one has a text comment as well as the diagram symbol.

[Event "?"]
[Site "?"]
[Date "2017.05.01"]
[Round "?"]
[White "W"]
[Black "B"]
[Result "1-0"]
[ECO "B00"]
[PlyCount "5"]
[SourceDate "2017.05.01"]
[SourceVersionDate "2017.05.01"]

1. e4 g5 2. d4 f6 3. Qh5# {[#]} 1-0

Here the diagram is at the end of the game.

Is it possible for the tool to deal with these cases?

Many thanks.
John
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Tool to extract parts of games from pgn file

Post by Ferdy »

JohnS wrote:Hi Ferdy

The following games cause problems and the tool doesn't work.

[Event "?"]
[Site "?"]
[Date "2017.05.01"]
[Round "?"]
[White "W"]
[Black "B"]
[Result "1-0"]
[ECO "B00"]
[PlyCount "5"]
[SourceDate "2017.05.01"]
[SourceVersionDate "2017.05.01"]

1. e4 g5 2. d4 f6 {[#] a blunder} 3. Qh5# 1-0

This one has a text comment as well as the diagram symbol.

[Event "?"]
[Site "?"]
[Date "2017.05.01"]
[Round "?"]
[White "W"]
[Black "B"]
[Result "1-0"]
[ECO "B00"]
[PlyCount "5"]
[SourceDate "2017.05.01"]
[SourceVersionDate "2017.05.01"]

1. e4 g5 2. d4 f6 3. Qh5# {[#]} 1-0

Here the diagram is at the end of the game.

Is it possible for the tool to deal with these cases?

Many thanks.
John
The first one is possible, but not sure about the second because that was already an end position, it would produce 2 same position, is it really needed?
JohnS
Posts: 215
Joined: Sun Feb 24, 2008 2:08 am

Re: Tool to extract parts of games from pgn file

Post by JohnS »

Hi Ferdy

Sorry, my second example is poor because the game ends in mate. Here's a better but still silly example.

[Event "?"]
[Site "?"]
[Date "2017.05.01"]
[Round "?"]
[White "W"]
[Black "B"]
[Result "1-0"]
[ECO "B00"]
[PlyCount "5"]
[SourceDate "2017.05.01"]
[SourceVersionDate "2017.05.01"]

1. e4 f6 2. d4 h6 3. Qh5+ {[#]} 1-0

So here the idea is to analyse from the last move to find out why Black resigned.

I hope this example is clearer.

Thanks.
John