I need a tool to delete all moves from a database, remaining only the initial positions of each "problem".
Database is in chessbase format, but obviously I can convert it to pgn first.
Tool
Moderators: hgm, Rebel, chrisw
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Tool
Can you show in the pgn format an example, both the original and the final output format?Ponti wrote:I need a tool to delete all moves from a database, remaining only the initial positions of each "problem".
Database is in chessbase format, but obviously I can convert it to pgn first.
-
- Posts: 27791
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Tool
Seems to me such a tool is called a text editor. Just delete all lines from the PGN except the FEN tag, and then the [FEN " prefix and the "] suffix, and you have a file of FENs. Five commands in ed.
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: Tool
Or less, in Windows command prompt:hgm wrote:Seems to me such a tool is called a text editor. Just delete all lines from the PGN except the FEN tag, and then the [FEN " prefix and the "] suffix, and you have a file of FENs. Five commands in ed.
Code: Select all
sort db.pgn>fen.txt
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Tool
@Aloisio:stegemma wrote:Or less, in Windows command prompt:hgm wrote:Seems to me such a tool is called a text editor. Just delete all lines from the PGN except the FEN tag, and then the [FEN " prefix and the "] suffix, and you have a file of FENs. Five commands in ed.
then edit the file and keep only the lines with [FEN...], that are all grouped together!Code: Select all
sort db.pgn>fen.txt
At Windows command prompt:
Code: Select all
findstr "FEN " db.pgn | sort > fen.txt
In UNIX-like shell (e.g. Cygwin bash):
Code: Select all
grep 'FEN ' db.pgn | sed 's/^.FEN "\(.*\)"$/\1/' | sort -u > fen.txt
-
- Posts: 493
- Joined: Wed Mar 15, 2006 6:13 am
- Location: Curitiba - PR - BRAZIL
Re: Tool
Ok, but... what if I have a file with 5.000 positions with the answers, I want to delete the answers and get only the diagrams.
To edit that manually... oh... 5.000 games ?
Is there another way to do it ?
To edit that manually... oh... 5.000 games ?
Is there another way to do it ?
A. Ponti
AMD Ryzen 1800x, Windows 10.
FIDE current ratings: standard 1913, rapid 1931
AMD Ryzen 1800x, Windows 10.
FIDE current ratings: standard 1913, rapid 1931
-
- Posts: 27791
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Tool
That is not more work (for you) than editing a single game, right? Most editors have a 'Replace all' command. Even MS NotePad. All is all. Even when it are a million games. Just takes the computer a bit longer.
-
- Posts: 493
- Joined: Wed Mar 15, 2006 6:13 am
- Location: Curitiba - PR - BRAZIL
Re: Tool
Thanks and sorry to bother you.
I´m not a programmer.
With your help I managed to do it !
After extracting only the [FEN ...] and using notepad, I converted the epd file back again to another .pgn file. Now I have only the positios, without the answers.
It was a .cbh file, converted to .pgn, of all positions in a book (by Andrei Volokitin), commented in russian (well, I can´t read russian).
I´m not a programmer.
With your help I managed to do it !
After extracting only the [FEN ...] and using notepad, I converted the epd file back again to another .pgn file. Now I have only the positios, without the answers.
It was a .cbh file, converted to .pgn, of all positions in a book (by Andrei Volokitin), commented in russian (well, I can´t read russian).
A. Ponti
AMD Ryzen 1800x, Windows 10.
FIDE current ratings: standard 1913, rapid 1931
AMD Ryzen 1800x, Windows 10.
FIDE current ratings: standard 1913, rapid 1931