Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Explode PGN to ply at a time tool?

Author: Andrew Dados

Date: 15:35:51 05/10/00

Go up one level in this thread


On May 10, 2000 at 16:02:25, Dann Corbit wrote:

>Suppose I have some PGN game like this:
>[Event "?"]
>[Site "?"]
>[Date "????.??.??"]
>[Round "?"]
>[White "?"]
>[Black "?"]
>[Result "0-1"]
>[ECO "A02"]
>[Opening "Bird's opening"]
>[Variation "Fool's Mate"]
>
>1. f4 e6 2. g4 Qh4# 0-1
>
>And I want to expand it so that the moves are expanded like this:
>1. f4
>1. ... e6
>2. g4
>2. ... Qh4#
>
>Is there some tool available that will do this automatically?  I think it would
>be handy for hand annotation of game scores.  E.g.:
>
>1. f4 {not my personal choice of a good opening but playable [not a gambit fan]}
>1. ... e6 {someone is playing you for a fool}
>2. g4 {you are one.}
>2. ... Qh4# {see?}

If you have perl handy, try this one-liner:

perl -00pe "s{(\d+\.)([\s\n]+)(\S+)([\s\n]+)(\S+)([\s\n]+)}{$1 $3\n$1 ...
$5\n}gs;" < 1.pgn > 2.pgn

It should work just fine assuming no comments in input file...
-Andrew-



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.