Reply
 
LinkBack Thread Tools Display Modes
  #1   Report Post  
Old February 6th 04, 03:28 AM
Mogath3
 
Posts: n/a
Default PGN Software

I'm looking for something that will trim down the header information in a pgn
file. Something like this:

[Event "?"]
[Site "DSB-2.Kongress"]
[Date "1881.??.??"]
[Round "13"]
[White "Blackburne,J"]
[Black "Chigorin,M"]
[Result "1-0"]
[ECO "D05"]

to something like this:


[White "Blackburne,J"]
[Black "Chigorin,M"]
[Result "1-0"]

Is there something out there that will do this for me with existing pgn files?
Doing it with a word processor is very time consuming. Thanks for any help
provided.

Regards,
Jeff

  #2   Report Post  
Old February 6th 04, 04:48 AM
electron
 
Posts: n/a
Default PGN Software

Mogath3 wrote:

I'm looking for something that will trim down the header information in a
pgn file. Something like this:

[Event "?"]
[Site "DSB-2.Kongress"]
[Date "1881.??.??"]
[Round "13"]
[White "Blackburne,J"]
[Black "Chigorin,M"]
[Result "1-0"]
[ECO "D05"]

to something like this:


[White "Blackburne,J"]
[Black "Chigorin,M"]
[Result "1-0"]

Is there something out there that will do this for me with existing pgn
files? Doing it with a word processor is very time consuming. Thanks for
any help provided.


Relatively easy to do with a Perl or Python script. I don't know of any
available application that already does this.

  #3   Report Post  
Old February 6th 04, 11:46 AM
David Richerby
 
Posts: n/a
Default PGN Software

Mogath3 wrote:
I'm looking for something that will trim down the header information in
a pgn file. Something like this:


I'm not sure if there's any software that will do what you want because
the Event, Site, Date, Round, White, Black and Result tags are,
technically, mandatory. I infer that, since you mention using a word
processor, you're using Windows so there aren't any convenient scripting
languages available.


Dave.

--
David Richerby Carnivorous Chicken (TM): it's like
www.chiark.greenend.org.uk/~davidr/ a farm animal but it eats flesh!
  #4   Report Post  
Old February 6th 04, 12:31 PM
JohnBoy
 
Posts: n/a
Default PGN Software

you're using Windows so there aren't any convenient
scripting languages available.


Dave.


just dl perl for windows. works like a charm

--
JB
  #5   Report Post  
Old February 6th 04, 07:41 PM
Cesar A. K. Grossmann
 
Posts: n/a
Default PGN Software

Mogath3 wrote:

I'm looking for something that will trim down the header information in a pgn
file. Something like this:


You can use a grep command if you are using Linux or if you can install
it someway (like installing Cygwin in a Windows box). The truth is that
if you have Linux, you have more than one way to do this (just now I can
think in sed, grep, awk, perl, but probably there's more, like making a
seletive delete in vi - an editor).

Using GNU Grep (Cygwin in a Windows 2000 box):

$ cat pgn-tags.txt
[Event "?"]
[Site "DSB-2.Kongress"]
[Date "1881.??.??"]
[Round "13"]
[White "Blackburne,J"]
[Black "Chigorin,M"]
[Result "1-0"]
[ECO "D05"]

$ cat pgn-tags.txt | grep -v "Site\|Round\|ECO\|Event\|Date"
[White "Blackburne,J"]
[Black "Chigorin,M"]
[Result "1-0"]

[]s
--
..O. Cesar A. K. Grossmann ICQ UIN: 35659423
...O http://www.LinuxByGrossmann.cjb.net/
OOO Quidquid Latine dictum sit, altum viditur



  #6   Report Post  
Old February 6th 04, 09:02 PM
a_fish
 
Posts: n/a
Default PGN Software

Hi!

i might be wrong here, but what i believe you need is
2 unix utility called 'egrep' and 'cat'. those are
now ported to win32 environment, so you can download
them either from :

http://unxutils.sourceforge.net/
(download UnxUtils.zip)

or alternatively from :

http://www.chasmer.com/PC/
(just download cat.exe and egrep.exe)

later, drop them into your windows map. (different
depending on your OS) but the idea is that you can issue
these commands from a dos prompt.

then at a dos prompt, type this :

cat BigGameEvents.pgn | egrep '(Event|Site|Date)' BigFiltered.pgn

the command 'cat' can be exchanged with native dos 'type' command as
well.

i think the best software for this purpose without going through
all command line is SCID. you simply choose not to view Event and
Site, etc.. in game list.
  #7   Report Post  
Old February 9th 04, 10:37 AM
David Richerby
 
Posts: n/a
Default PGN Software

Cesar A. K. Grossmann wrote:
$ cat pgn-tags.txt | grep -v "Site\|Round\|ECO\|Event\|Date"
[White "Blackburne,J"]
[Black "Chigorin,M"]
[Result "1-0"]


Careful, now: that will remove any lines containing comments with any of
those words in and will leave any tags apart from the listed ones, which
isn't the behaviour the OP wanted (which was to remove all tags apart from
White, Black and Result).

And why use cat to pipe a file to grep? grep takes a list of files as
arguments after the regular expression.

grep -v "Site\|Round\|ECO\|Event\|Date" pgn-tags.txt

does exactly the same thing and saves copying the whole file through a
pipe into a different process. The version without the pipe seems to be
about 10% faster on my system but, since it does about 15Mb per second,
unless you're dealing with vast PGN files, the main saving is in the
typing. :-)


Dave.

--
David Richerby Simple Windows (TM): it's like a
www.chiark.greenend.org.uk/~davidr/ graphical user interface but it has
no moving parts!
  #8   Report Post  
Old February 9th 04, 12:22 PM
Cesar A. K. Grossmann
 
Posts: n/a
Default PGN Software

David Richerby wrote:

Careful, now: that will remove any lines containing comments with any of
those words in and will leave any tags apart from the listed ones, which
isn't the behaviour the OP wanted (which was to remove all tags apart from
White, Black and Result).


I think that with grep, it's this what you can do. But you are right,
the most correct approach to the problem is to filter this way:

if it is a line with a tag, let pass only if the tag is White, Black or
Result
else let it pass.

So, the next step is to wrote a more complex filter (I don't know how to
do that with grep), and perhaps using sed or awd, or even Perl.

And why use cat to pipe a file to grep? grep takes a list of files as
arguments after the regular expression.


I'm used to do this way... I start with a cat command, to see what the
file has. Then I add a pipe and a filtering command, and...

[]s
--
..O. Cesar A. K. Grossmann ICQ UIN: 35659423
...O http://www.LinuxByGrossmann.cjb.net/
OOO Quidquid Latine dictum sit, altum viditur

http://www.clickfome.com.br/ - Clique e doe!
Soja Transgênica: http://tinyurl.com/2pfou

  #9   Report Post  
Old February 9th 04, 01:33 PM
David Richerby
 
Posts: n/a
Default PGN Software

Cesar A. K. Grossmann wrote:
So, the next step is to wrote a more complex filter (I don't know how to
do that with grep), and perhaps using sed or awd, or even Perl.


Yes. Now that I'm awake, the following does the trick:

perl -i.bak -ne 'print if !/^\[/ || /^\[(White|Black|Result)\s/' file.pgn

This will remove all the tags from file.pgn except for White, Black and
Results. The original file will be saved as file.pgn.bak just in case
something goes wrong. I believe this code works but offer no guarantees.


Dave.

--
David Richerby Miniature Windows (TM): it's like a
www.chiark.greenend.org.uk/~davidr/ graphical user interface but you can
hold in it your hand!
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fair warning to all fellow chess players.....Avoid the well-known liar and thief Mike Leahy with his ripoff software "Bookup".........stick to reputable chess software companies such as Chessbase, Convekta, etc Debbie Bauer Sucks Dick for Loose Change rec.games.chess.analysis (Chess Analysis) 0 March 8th 04 09:15 AM
CD-ROM trouble: Installing chess games software on SunPCi card. Dr. David Kirkby rec.games.chess.computer (Computer Chess) 0 January 10th 04 11:11 AM
Comparison of Chess Software Antonio R. rec.games.chess.computer (Computer Chess) 9 January 6th 04 08:32 PM
Will Chessbase address software weakness in positional understanding? Alberich rec.games.chess.computer (Computer Chess) 13 December 4th 03 07:58 PM
Kasparov's remarks about chess software had answers staring him in the face Alberich rec.games.chess.analysis (Chess Analysis) 3 November 22nd 03 10:00 PM


All times are GMT +1. The time now is 12:53 PM.

Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright ©2004-2019 ChessBanter.
The comments are property of their posters.
 

About Us

"It's about Chess"

 

Copyright © 2017