Here is utility to strip comments from the PGN file

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

Moderators: hgm, Rebel, chrisw

Dragan
Posts: 108
Joined: Mon Aug 06, 2012 1:55 pm

Here is utility to strip comments from the PGN file

Post by Dragan »

I had trouble finding such utility. I know you can use Scid, but I wanted something simple. So I wrote a small program that some of you may find useful.
I use it to strip comments and select only long games from playchessenginegames.pgn.
Here is the link to it:
http://nebula.host-ed.me/StripPgn.html
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Here is utility to strip comments from the PGN file

Post by jdart »

pgn-extract can do this (use the -C option).

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

--Jon
Dragan
Posts: 108
Joined: Mon Aug 06, 2012 1:55 pm

Re: Here is utility to strip comments from the PGN file

Post by Dragan »

Thanks for the info.
pgn-extract seems to be 20 times slower then my utility.
Can it filter by time control?

I also prefer to break new lines only after full moves. Don't like when move is broken in 2 lines.
Norm Pollock
Posts: 1056
Joined: Thu Mar 09, 2006 4:15 pm
Location: Long Island, NY, USA

Re: Here is utility to strip comments from the PGN file

Post by Norm Pollock »

Dragan wrote:Thanks for the info.
pgn-extract seems to be 20 times slower then my utility.
Can it filter by time control?

I also prefer to break new lines only after full moves. Don't like when move is broken in 2 lines.
My utility "trim" almost all you are asking and more. From its readme file:

Code: Select all


"trim" produces an output "pgn" file that puts each "full move" on
the same line while also removing comments, if present. "trim" lets
you set the maximum output width in the "Move" section from 40 to 
100 characters. The default is 76 characters.

"trim" removes comments, nags, variations and major symbolic
annotation symbols (!, !!, ?, ??, !?, ?!, +-, -+, +/-, -/+, +=,
=+, +/=, =/+, =, ~, and N), if present.

If needed, "trim" inserts a space (" ") after a move number.
For example, "1.e4" becomes "1. e4".

"trim" changes any occurrences of numerical castling notation 
("0-0", "0-0-0") to alphabetical ("O-O", "O-O-O").

Syntax: trim filename.pgn

        trim filename.pgn [output_width]

Usage:  trim alpha.pgn

        trim alpha.pgn 60

Output: outR.pgn

Comments"

     1. Execution time is affected by the size of the input "pgn" file.

Dragan
Posts: 108
Joined: Mon Aug 06, 2012 1:55 pm

Re: Here is utility to strip comments from the PGN file

Post by Dragan »

LOL :)
This was exactly what I wanted but couldn't find anywhere.
Now don't add filtering for time control. I don't want to feel like I wasted my time completely :)
Adam Hair
Posts: 3226
Joined: Wed May 06, 2009 10:31 pm
Location: Fuquay-Varina, North Carolina

Re: Here is utility to strip comments from the PGN file

Post by Adam Hair »

Norm is a big reason why I have not yet learned how to write my own utilities. If there is something I want to do with a pgn or epd, most of the time I can use one or more of his utilities to do it.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: Here is utility to strip comments from the PGN file

Post by Don »

Dragan wrote:Thanks for the info.
pgn-extract seems to be 20 times slower then my utility.
Can it filter by time control?

I also prefer to break new lines only after full moves. Don't like when move is broken in 2 lines.
pgn-extract isn't just stripping comments, it's also cleaning up any incorrect PGN so that slows it down.

However it's really fast - so unless you have millions of games it should be fast enough, no?

Don
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.