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
Here is utility to strip comments from the PGN file
Moderators: hgm, Rebel, chrisw
-
- Posts: 108
- Joined: Mon Aug 06, 2012 1:55 pm
-
- 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
pgn-extract can do this (use the -C option).
http://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/
--Jon
http://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/
--Jon
-
- Posts: 108
- Joined: Mon Aug 06, 2012 1:55 pm
Re: Here is utility to strip comments from the PGN file
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 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.
-
- 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
My utility "trim" almost all you are asking and more. From its readme file: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.
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.
-
- Posts: 108
- Joined: Mon Aug 06, 2012 1:55 pm
Re: Here is utility to strip comments from the PGN file
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
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
-
- 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
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.
-
- Posts: 5106
- Joined: Tue Apr 29, 2008 4:27 pm
Re: Here is utility to strip comments from the PGN file
pgn-extract isn't just stripping comments, it's also cleaning up any incorrect PGN so that slows it down.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.
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.