Compare pgn data quickly How?

Moderators: Elijah, Igbo, timetraveller

Kater Carlo

Top contribute Forum
Forum Contributions
Points: 17 742,00 
Posts: 83
Joined: 04/11/2019, 18:06
Status: Offline (Active 13 Hours, 15 Minutes ago)
Medals: 1
Topics: 6
Reputation: 160
Has thanked: 385 times
Been thanked: 292 times

Compare pgn data quickly How?

Post by Kater Carlo »

I have a question about pgn databases. Now and again, the need arises where I want to compare two similar pgn databases to highlight the exact differences between them and give the different games in a new pgn database.. How to do this quickly? Happy about suggestions :to_become_senile:
Nemesis

Top contribute Forum Top Active Users
Forum Contributions
Points: 33 999,00 
Posts: 2585
Joined: 05/02/2020, 10:42
Status: Offline (Active 1 Month, 3 Days, 14 Hours ago)
Medals: 2
Topics: 194
Reputation: 7481
Has thanked: 6579 times
Been thanked: 6863 times

Compare pgn data quickly How?

Post by Nemesis »

PGN files are basically text files so a text editor such as NotePad++ for example would have a Compare plugin which would allow you to compare two PGN files. You would still need to extract the differences or whatever you're looking for via regex. I wrote the regex code a while ago - regrettably my filing system is the PITS so unable to help.

I usually just alter the extension from pgn to txt and do whatever text manipulation I need to.

Edit : try WinMerge .. :handgestures-thumbup:
Kater Carlo

Top contribute Forum
Forum Contributions
Points: 17 742,00 
Posts: 83
Joined: 04/11/2019, 18:06
Status: Offline (Active 13 Hours, 15 Minutes ago)
Medals: 1
Topics: 6
Reputation: 160
Has thanked: 385 times
Been thanked: 292 times

Compare pgn data quickly How?

Post by Kater Carlo »

Thanks Nemesis! WinMerge will do the task for .txt. NotePad++ is also good, however a little bit slow for several thousand games comparison. thankyou
IVAN_ALEXEEV
Inactive User
Points: 64,00 
Posts: 17
Joined: 05/07/2020, 4:23
Status: Offline (Active 2 Weeks, 2 Days, 23 Hours, 53 Minutes ago)
Topics: 0
Reputation: 32
Has thanked: 1247 times
Been thanked: 42 times

Compare pgn data quickly How?

Post by IVAN_ALEXEEV »

There is a utility - pgn-extract. It has this function.
Nemesis

Top contribute Forum Top Active Users
Forum Contributions
Points: 33 999,00 
Posts: 2585
Joined: 05/02/2020, 10:42
Status: Offline (Active 1 Month, 3 Days, 14 Hours ago)
Medals: 2
Topics: 194
Reputation: 7481
Has thanked: 6579 times
Been thanked: 6863 times

Compare pgn data quickly How?

Post by Nemesis »

IVAN_ALEXEEV wrote: 09/09/2023, 16:21 There is a utility - pgn-extract. It has this function.
Could you be a little more specific please Ivan ?
I was unable to find a flag/command line argument that compares PGN files.
sarona

Top contribute Forum
Chief moderators
Points: 20 167,00 
Forum Contributions
Posts: 227
Joined: 14/08/2022, 20:09
Status: Offline (Active 8 Hours, 39 Minutes ago)
Medals: 1
Topics: 8
Reputation: 1784
Has thanked: 360 times
Been thanked: 1463 times

Compare pgn data quickly How?

Post by sarona »

Kater Carlo wrote: 09/09/2023, 13:05 I have a question about pgn databases. Now and again, the need arises where I want to compare two similar pgn databases to highlight the exact differences between them and give the different games in a new pgn database.. How to do this quickly? Happy about suggestions :to_become_senile:
Use SQL.

Nguyen Hong Pham has produced an excellent SQL tool for PGNs called Open Chess Game Database Standard (OCGDB).
https://github.com/nguyenpham/ocgdb

It is lightning fast for large databases/multiiple PGNs. You can compare PGNs with ease once you learn basic SQL syntax (not hard for the vast majority of people). This is far superior to a text editor and is what I use along with the SQLite GUI. I believe Pham has built OCGDB into the Banksia GUI as well.

There is a large thread over at Talkchess on OCGDB.
https://talkchess.com/forum3/viewtopic.php?f=7&t=78464&hilit=ocgdb
ConRog

Book Maker
Forum Contributions
Points: 11 599,00 
Posts: 314
Joined: 15/11/2019, 19:53
Status: Online (Active 2 Hours, 39 Minutes ago)
Medals: 1
Topics: 5
Reputation: 1036
Location: French Polynesia
Has thanked: 1125 times
Been thanked: 968 times

Compare pgn data quickly How?

Post by ConRog »

Hi,

Just install pgn-extract.exe in same directory as your .pgn databases and type command line :

pgn-extract -s 1.pgn -c2.pgn -D -o1minus2.pgn

It will remove duplicates games found in 2.pgn, from 1.pgn, and save result into 1minus2.pgn

Games are only considered to be duplicates on the basis of the moves played.

Also note that it is a subtraction, and not an "exclusive OR" . Therefore the games found in 2.pgn that are not it 1.pgn will not be in 1minus2.pgn

If you want to keep all the games from 1.pgn and 2.pgn but not the duplicates, you will to type 3 command lines :

pgn-extract -s 1.pgn -c2.pgn -D -o1minus2.pgn
pgn-extract -s 2.pgn -c1.pgn -D -o2minus1.pgn
copy /B 1minus2.pgn + 2minus1.pgn 1plus2no-dups.pgn

Best regards.
Kater Carlo

Top contribute Forum
Forum Contributions
Points: 17 742,00 
Posts: 83
Joined: 04/11/2019, 18:06
Status: Offline (Active 13 Hours, 15 Minutes ago)
Medals: 1
Topics: 6
Reputation: 160
Has thanked: 385 times
Been thanked: 292 times

Compare pgn data quickly How?

Post by Kater Carlo »

@ConRog Your solution is brilliant and ultra fast beers . This is what I was looking for.

The SQL solution is a choice only for people, who use it already in their daily work, in my view.
It is definitely not simple. OCDGB gave problems to me and I do not like to read tons
of large threads, before I can start. Maybe it is only my problem. sorry_1

WinMerge was new to me. It is also an interesting experience and of great value
for future analyses, however more time consuming.
IVAN_ALEXEEV
Inactive User
Points: 64,00 
Posts: 17
Joined: 05/07/2020, 4:23
Status: Offline (Active 2 Weeks, 2 Days, 23 Hours, 53 Minutes ago)
Topics: 0
Reputation: 32
Has thanked: 1247 times
Been thanked: 42 times

Compare pgn data quickly How?

Post by IVAN_ALEXEEV »

Nemesis wrote: 09/09/2023, 16:40
IVAN_ALEXEEV wrote: 09/09/2023, 16:21 There is a utility - pgn-extract. It has this function.
Could you be a little more specific please Ivan ?
I was unable to find a flag/command line argument that compares PGN files.
In the following example, we want to select games from 2.pgn that don't already exist in 1.pgn:
.\pgn-extract --checkfile 1.pgn -D -o 3.pgn 1.pgn 2.pgn
Post Reply

Return to “Programming, Technical Discussions, Chess related questions etc.”