Tool for truncate pgn files

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

Moderator: Ras

User avatar
Ozymandias
Posts: 1537
Joined: Sun Oct 25, 2009 2:30 am

Re: Tool for truncate PGN files.

Post by Ozymandias »

Norm Pollock wrote:
Ozymandias wrote:
Norm Pollock wrote:I'm thinking about modifying "tagNull" to replace tag values with a null value one tag type at a time. Perhaps the current way of replacing ALL tag values with a null value in one shot is too extreme.
You mean that if I write "tagNull alpha.pgn Round", is not just the "Round" tag that gets modified? I seem to recall it was.
Ooops!!! You are correct. My bad. The current version replaces tag values with a default value, ONE TAG TYPE AT A TIME. Please ignore my previous comments about tagNull. However my comment about "truncate" was correct.

Therefore, Carlos should NOT replace tag values with defaults for ECO and Result.
For a moment there, you gave me a scare. I used that exact syntax a couple of weeks ago (would've hated a need to retrace my steps). BTW, I noticed you modified gameSplit, and it can now create more than 20 files, that allows me to finally check the PGN file, without having to run that tool… twice.
Norm Pollock
Posts: 1087
Joined: Thu Mar 09, 2006 4:15 pm
Location: Long Island, NY, USA

Re: Tool for truncate PGN files.

Post by Norm Pollock »

Ozymandias wrote:
Norm Pollock wrote:
Ozymandias wrote:
Norm Pollock wrote:I'm thinking about modifying "tagNull" to replace tag values with a null value one tag type at a time. Perhaps the current way of replacing ALL tag values with a null value in one shot is too extreme.
You mean that if I write "tagNull alpha.pgn Round", is not just the "Round" tag that gets modified? I seem to recall it was.
Ooops!!! You are correct. My bad. The current version replaces tag values with a default value, ONE TAG TYPE AT A TIME. Please ignore my previous comments about tagNull. However my comment about "truncate" was correct.

Therefore, Carlos should NOT replace tag values with defaults for ECO and Result.
For a moment there, you gave me a scare. I used that exact syntax a couple of weeks ago (would've hated a need to retrace my steps). BTW, I noticed you modified gameSplit, and it can now create more than 20 files, that allows me to finally check the PGN file, without having to run that tool… twice.
You should have contacted me, pm or email, if you think there is a way to make a tool easier to use.
User avatar
Ozymandias
Posts: 1537
Joined: Sun Oct 25, 2009 2:30 am

Re: Tool for truncate PGN files.

Post by Ozymandias »

Ok, did that.
Elorejano
Posts: 167
Joined: Sat Mar 20, 2010 3:31 am

Re: Tool for truncate PGN files.

Post by Elorejano »

so, with your util, i must aply one by one?
Thanks
Norm Pollock
Posts: 1087
Joined: Thu Mar 09, 2006 4:15 pm
Location: Long Island, NY, USA

Re: Tool for truncate PGN files.

Post by Norm Pollock »

Elorejano wrote:so, with your util, i must aply one by one?
Thanks
Yes. And you have to rename the output as you go step by step. Here is an example:

Code: Select all

  tagNull alpha.pgn Event
  ren outH.pgn temp.pgn
  tagNull temp.pgn Site
  ren outH.pgn temp.pgn
  tagNull temp.pgn Round

The file "outH.pgn" will now have the tag types Event, Site and Round
set to their default values.
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: Tool for truncate pgn files

Post by MikeB »

Regarding the option --plylimit, it is not a ply limit, but a move limit. For example, say you would want limit the game to 10 moves for each side. That is 20 ply, but when you use "--plylimit 10" - it will limit the game to 20 ply ( 10 moves for each side ). The option is mislabeled, that's all. It does work.
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: Tool for truncate pgn files

Post by MikeB »

Elorejano wrote:Hi!
Truncate works fine but i couldnt change the tags.
With
--notags
tags disapears and i need them
Any help?
Thanks in advance
There is a little trick to get then back.

Say you run this:

Code: Select all

./pgn-extract --notags -nags  all16.pgn -o notag2.pgn
and this is your output.

Code: Select all

1. e4 c5 2. Nf3 Nc6 3. d4 cxd4 4. Nxd4 e6 5. Nc3 Nf6 6. Ndb5 d6 7. Bf4 e5
8. Bg5 a6 *

1. d4 Nf6 2. c4 e6 3. Nc3 Bb4 4. Qc2 O-O 5. a3 Bxc3+ 6. Qxc3 b6 7. Bg5 Bb7
8. f3 h6 *
 etc

1. e4 c5 2. Nf3 e6 3. d4 cxd4 4. Nxd4 Nc6 5. Nb5 d6 6. c4 Nf6 7. N1c3 a6 8.
Na3 Be7 *
Then run :

Code: Select all

./pgn-extract --plylimit 300 notag2.pgn -o addtags.pgn
da ta! your tags are back and they are blank!

Code: Select all

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]

1. e4 c5 2. Nf3 Nc6 3. d4 cxd4 4. Nxd4 e6 5. Nc3 Nf6 6. Ndb5 d6 7. Bf4 e5
8. Bg5 a6 *

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]

1. d4 Nf6 2. c4 e6 3. Nc3 Bb4 4. Qc2 O-O 5. a3 Bxc3+ 6. Qxc3 b6 7. Bg5 Bb7
8. f3 h6 *

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]

1. e4 c5 2. Nf3 e6 3. d4 cxd4 4. Nxd4 Nc6 5. Nb5 d6 6. c4 Nf6 7. N1c3 a6 8.
Na3 Be7 *
Elorejano
Posts: 167
Joined: Sat Mar 20, 2010 3:31 am

Re: Tool for truncate pgn files

Post by Elorejano »

Hi! All works.
But its imposible for programersfriends make a bat file for to make this process in one time? Sory, im not a programer
Cheers