Converting PGN variations to separate games?

Sort:
DeepGreene

I have a strong suspicion this is futile, but I thought I'd throw it out there...  :)

I've got a PGN database with a couple of dozen games that are individually pretty heavy on variation lines.  What I'm looking for is some kind of utility that is capable of consuming that PGN and outputting new PGN in which the variations are represented by separate games.

Doesn't exist, does it..  ?

rooperi

Hmm, try this....

Go through each variation, and promote that variation to the main line. Save as a new game. Repeat, again, and again, and again.......

DeepGreene
rooperi wrote:

Hmm, try this....

Go through each variation, and promote that variation to the main line. Save as a new game. Repeat, again, and again, and again.......


LOL.  Yes... yes.  I tried that a bit earlier and, unfortunately, it resulted in mild temporary insanity, followed by using my 'Time Machine' feature to blot the evidence of my manual manipulations from existence.  Yell

I might give it another try (I'm questioning whether or not it's worth it), but the variations here tend to be deep and nested.  This example was the one that broke me earlier:

[Event "Sicilian"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White ""]
[Black ""]
[Result "*"]
[PlyCount "25"]
[Opening "Sicilian, Taimanov V"]

1. e4 c5 2. Nc3 Nc6 (2... d6 3. f4 Nc6 4. Nf3 g6 5. Bb5 Bd7 (5... Bg7) 6. O-O
Bg7 7. d3 a6 (7... Nf6) 8. Bxc6 Bxc6 9. Be3 Nf6 10. h3 O-O 11. Qd2; 2... e6 3.
Nf3 a6 (3... Nc6 4. d4 cxd4 5. Nxd4 Qc7 (5... a6; 5... d6) 6. Be2 a6 (6... Nf6)
7. O-O Nf6 8. Be3 Bb4 (8... Be7) 9. Na4 Be7 (9... O-O 10. Nxc6 bxc6 11. Nb6 Rb8
12. Nxc8 Rfxc8 (12... Qxc8 13. e5) 13. Bxa6; 9... Bd6 10. g3 b5 11. Nb6 Rb8
(11... Qxb6 12. Nxb5 Bc5 13. Bxc5 Qxc5 14. Nc7+) 12. Nxc8 Rxc8 13. a4) 10. Nxc6
bxc6 11. Nb6 Rb8 12. Nxc8 Qxc8 13. Bd4; 3... d6 4. d4 cxd4 5. Nxd4 Nf6 6. Be2
Be7 7. O-O O-O 8. f4 Nc6 9. Be3 Bd7 10. Nb3; 3... Nf6 4. e5 Nd5 5. Nxd5 exd5 6.
d4 Nc6 7. dxc5 Bxc5 8. Qxd5 Qb6 9. Bc4 Bxf2+ 10. Ke2 O-O 11. Rf1 Bc5 12. Ng5
Nd4+ 13. Kd1 Ne6 14. Ne4 d6 15. exd6 Rd8 16. Bd3 Bxd6 17. Nxd6 Qxd6 18. Qf5))
3. Nf3 e6 (3... d6 4. d4 cxd4 5. Nxd4 Nf6 6. Bg5; 3... g6; 3... e5; 3... Nf6)
4. d4 cxd4 5. Nxd4 Qc7 (5... a6; 5... d6) 6. Be2 a6 (6... Nf6) 7. O-O Nf6 8.
Be3 Bb4 (8... Be7) 9. Na4 Be7 (9... O-O 10. Nxc6 bxc6 11. Nb6 Rb8 12. Nxc8
Rfxc8 (12... Qxc8 13. e5) 13. Bxa6; 9... Bd6 10. g3 b5 11. Nb6 Rb8 (11... Qxb6
12. Nxb5 Bc5 13. Bxc5 Qxc5 14. Nc7+) 12. Nxc8 Rxc8 13. a4) 10. Nxc6 bxc6 11.
Nb6 Rb8 12. Nxc8 Qxc8 13. Bd4  *

It's my own fault.  When I exported this data from a repertoire file in Chess Position Trainer (whose original data is now history unfortunately) I was given the choice to export as a single game or a separate game for every line.

I erred, apparently.

Ousland

 

I used CPT some years ago, are you sure that you can not import a game with variation and them export again with the correct option? I think is posible

PD: I changed CPT to scid the day I discover the function called "mask" in scid. Ok CPT is for training purposes, but I only used it to save my repertory that´s why I chose scid 

Chessmo

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

jassimmohd

1-MAKE A FOLDER

2-PUT INSIDE A COPY OF SINGLE PGN FILE OF ANY PREVIOUSLY SAVED GAME, OPEN IT IN TEXT AND ERASE ALL WHAT IS WRITTEN INSIDE AS TEXT, THEN SAVE. (THIS AVOID OVERIDE BY PREVIOUS GAME)

3-MAKE MORE COPIES OF THIS PGN FILE INSIDE THE FOLDER, REPEAT UNTIL MATCH THE SAME NUMBER OF GAMES IN THE ORIGINAL MULTIGAMES FILE

4-RENAME ALL NEW PGN FILES WITH A LITTER, FOR EXAMPLE A (1). A (2)....A (N)

5-OPEN MULTIGAME FILE IN TEXT , COPY CONTENT AND PASTE IN A NEW PLANK TEXT DOCUMENT AND SAVE.

6- CUT FIRST GAME INFORMATION FROM THE SAVED TEXT, OPEN FIRST PGN, EDIT, PASTE INTO NEW GAME. SAVE.

7- REPEAT FOR ALL TILL FINISH.

 

jassimmohd
jassimmohd wrote:

1-MAKE A FOLDER

2-PUT INSIDE A COPY OF SINGLE PGN FILE OF ANY PREVIOUSLY SAVED GAME, OPEN IT IN TEXT AND ERASE ALL WHAT IS WRITTEN INSIDE AS TEXT, THEN SAVE. (THIS AVOID OVERIDE BY PREVIOUS GAME)

3-MAKE MORE COPIES OF THIS PGN FILE INSIDE THE FOLDER, REPEAT UNTIL MATCH THE SAME NUMBER OF GAMES IN THE ORIGINAL MULTIGAMES FILE

4-RENAME ALL NEW PGN FILES WITH A LITTER, FOR EXAMPLE A (1). A (2)....A (N)

5-OPEN MULTIGAME FILE IN TEXT , COPY CONTENT AND PASTE IN A NEW PLANK TEXT DOCUMENT AND SAVE.

6- CUT FIRST GAME INFORMATION FROM THE SAVED TEXT, OPEN FIRST PGN, EDIT, PASTE INTO NEW GAME. SAVE.

7- REPEAT FOR ALL TILL FINISH.

 

Tip:

If there is a lot of data (hundreds of games), you can perform faster by changing the pgn file property to open with notepad, to open them faster and paste directly there.

Return the original file property when finish.

jassimmohd

Another method for splitting huge pgn files very fast, (this tricky way is my own idea.)

1- Use free program gsplit 

https://www.gdgsoft.com/gsplit

an old program originally used to split big files in order to email them or store them in old fashion diskettes (abonded)

1-open the multi-game pgn file in text and copy all

2- paste in word doc

3- make a separation argument (by inserting non executable character in the word doc).

find: [Event "

replace with: --finish--^p[Event "

click replace all

(you will see each game separated by a line) --finish--

erase only the top --finish-- one because there is no game above it.

4- cut all word doc text and insert it into a template  pgn (any previously saved pgn) opened in text.

5- Open gsplit 

6-select the file to open (the pgn file already edited), and your destination folder.

7- in pieces field, make these settings:

Type and Size
I want to split after nth ocurance:
1
of this pattern:
--finish--

8- in Filenames field:

Piece Name Mask:
game{num}{orf}

(this is important to preserve the original pgn extention)

8- in Other Properties field:

tick Do not add GSplit tags to piece files

this tag contains information of rejoining splitted files, but turn them unreadable.

9- Click Split, the file will be splitted in seconds.

note: If you have multiple files to work, keep the program open to retain these settings, so your work is just editing word docs and pgn files, and Clicking Split in between.

EscherehcsE

+1

@DeepGreene, I haven't tried this, so I don't *know* that it works, but in theory it sounds like what you're looking for.

https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#splitvariants

 

Martin_Stahl
EscherehcsE wrote:

+1

@DeepGreene, I haven't tried this, so I don't *know* that it works, but in theory it sounds like what you're looking for.

https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#splitvariants

 

 

Only took 11 years

EscherehcsE
Martin_Stahl wrote:
EscherehcsE wrote:

+1

@DeepGreene, I haven't tried this, so I don't *know* that it works, but in theory it sounds like what you're looking for.

https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#splitvariants

 

 

Only took 11 years

We jump right on those things! :-)

Still faster than a membership refund from support... :-P

jassimmohd
EscherehcsE wrote:

+1

@DeepGreene, I haven't tried this, so I don't *know* that it works, but in theory it sounds like what you're looking for.

https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#splitvariants

 

This procedure behind this idea is by incorporating some programming methods that rely on operating system commands to carry on.

As there no programming interface to work through, it is therefore difficult and slow. Just read the user manual to end up with just headache.

In general, all free methods almost rely on operating system commands although the programming background for the all procedure and interface is very simple.

On the other-hand, third party programs are rare and not open source, for example

http://www.pgnmentor.com/index.html

There is no reliable online method that can deal with pgn text files.

EscherehcsE
jassimmohd wrote:
EscherehcsE wrote:

+1

@DeepGreene, I haven't tried this, so I don't *know* that it works, but in theory it sounds like what you're looking for.

https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#splitvariants

 

This procedure behind this idea is by incorporating some programming methods that rely on operating system commands to carry on.

As there no programming interface to work through, it is therefore difficult and slow. Just read the user manual to end up with just headache.

In general, all free methods almost rely on operating system commands although the programming background for the all procedure and interface is very simple.

On the other-hand, third party programs are rare and not open source, for example

http://www.pgnmentor.com/index.html

There is no reliable online method that can deal with pgn text files.

I'm not sure I understand you. Are you saying that pgn-extract is unreliable, or that it's just slow? I've used pgn-extract a few other times for other purposes, and I've always been happy with the results.

jassimmohd
EscherehcsE wrote:
jassimmohd wrote:
EscherehcsE wrote:

+1

@DeepGreene, I haven't tried this, so I don't *know* that it works, but in theory it sounds like what you're looking for.

https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#splitvariants

 

This procedure behind this idea is by incorporating some programming methods that rely on operating system commands to carry on.

As there no programming interface to work through, it is therefore difficult and slow. Just read the user manual to end up with just headache.

In general, all free methods almost rely on operating system commands although the programming background for the all procedure and interface is very simple.

On the other-hand, third party programs are rare and not open source, for example

http://www.pgnmentor.com/index.html

There is no reliable online method that can deal with pgn text files.

I'm not sure I understand you. Are you saying that pgn-extract is unreliable, or that it's just slow? I've used pgn-extract a few other times for other purposes, and I've always been happy with the results.

Sure It is reliable but difficult for people who didnt get use with operating system commands.

If you are familiar with and happy, that is great.!!

EscherehcsE
jassimmohd wrote:
EscherehcsE wrote:
jassimmohd wrote:
EscherehcsE wrote:

+1

@DeepGreene, I haven't tried this, so I don't *know* that it works, but in theory it sounds like what you're looking for.

https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#splitvariants

 

This procedure behind this idea is by incorporating some programming methods that rely on operating system commands to carry on.

As there no programming interface to work through, it is therefore difficult and slow. Just read the user manual to end up with just headache.

In general, all free methods almost rely on operating system commands although the programming background for the all procedure and interface is very simple.

On the other-hand, third party programs are rare and not open source, for example

http://www.pgnmentor.com/index.html

There is no reliable online method that can deal with pgn text files.

I'm not sure I understand you. Are you saying that pgn-extract is unreliable, or that it's just slow? I've used pgn-extract a few other times for other purposes, and I've always been happy with the results.

Sure It is reliable but difficult for people who didnt get use with operating system commands.

If you are familiar with and happy, that is great.!!

Ok, now I understand - Yes, it's a command-line program; I have no problem with that. (I used DOS back in the age of dinosaurs, and now I'm using Linux and actually pull up the terminal from time to time...)

RoombarevoL

@chessmo Thanks man, this helped a LOT!

Chessmo
Raffa05 wrote:

@chessmo Thanks man, this helped a LOT!

Glad to hear!