program to remove the round in a pgn database header

Discussions about Winboard/Xboard. News about engines or programs to use with these GUIs (e.g. tournament managers or adapters) belong in this sub forum.

Moderator: Andres Valverde

program to remove the round in a pgn database header

Postby Roy Harper » 11 Feb 2005, 03:39

the header has [Round "?"] in it from Scid when i sort the games
how do i remove this other than manually?
Please someone has to know :)
I tried winedit but cant get it to do it with out leaving a blank space.
I am using winxp in case that makes differance
Roy Harper
 
Posts: 15
Joined: 13 Nov 2004, 17:52

Re: program to remove the round in a pgn database header

Postby Michael Yee » 11 Feb 2005, 03:52

With NoteTab Light (freely available) you can do a "find and replace" where you replace

[Round "?"]^p

with

*nothing*

where *nothing* really means keeping the "Replace with:" text box empty.

This will remove the newline, too, due to the "^p".
Michael Yee
 
Posts: 51
Joined: 26 Sep 2004, 19:49

Re: program to remove the round in a pgn database header

Postby Roy Harper » 11 Feb 2005, 04:20

Ok i did that and got a *nothing* in same space as the [White etc
did a replace *nothing* and it set the header right hehe.
Roy Harper
 
Posts: 15
Joined: 13 Nov 2004, 17:52

Re: program to remove the round in a pgn database header

Postby Tim Foden » 11 Feb 2005, 09:17

Roy Harper wrote:the header has [Round "?"] in it from Scid when i sort the games
how do i remove this other than manually?
Please someone has to know :)
I tried winedit but cant get it to do it with out leaving a blank space.
I am using winxp in case that makes differance


Make a note of the full path and name of the file. For my example I will assume that it is this:

D:\chess\pgns\db1.pgn

where D: is the drive, and \chess\pgns is the directory the file is on on drive D: and db1.pgn is the name of the file. We're going to create a new file in the same directory called db2.pgn.

Open a Command Prompt and type this {ENTER} means press Enter or Carriage Return key:

d: {ENTER}
cd \chess\pgns {ENTER}
find /v /i "[round" db1.pgn > db2.pgn {ENTER}


Cheers, Tim.
Tim Foden
 

Re: program to remove the round in a pgn database header

Postby Igor Gorelikov » 11 Feb 2005, 11:05

You can do dit with sed:

sed "s/Round .?//" input_file > output_file

Better use the batch file with this line.
Igor
User avatar
Igor Gorelikov
 
Posts: 153
Joined: 27 Sep 2004, 10:12
Location: St. Petersburg, Russia

Re: program to remove the round in a pgn database header

Postby Sven Schüle » 11 Feb 2005, 15:07

Igor Gorelikov wrote:You can do dit with sed:

sed "s/Round .?//" input_file > output_file

Better use the batch file with this line.
Igor
Hi Igor,

1) "sed" is only available under UNIX, or with CygWin or any other "UNIX emulation" environment on non-UNIX platforms. So I'm not sure whether Roy can use it.

2) With "sed" commands starting with the letter 's' (for 'substitute') you can't remove whole lines but only change lines. As far as I know there is no multi-line replacement using '\n' on the left side (but I may be wrong).

3) Your given "sed" command transforms lines of the form [Round "?"] into ["]. I think you meant this:
Code: Select all
sed 's/^\[Round "?"\]$//' input_file > output_file

which replaces such lines with an empty line (still not the solution).

4) "find /v /i ..." in a DOS shell (or batch), as pointed out by Tim, looks good and should solve the problem. Under UNIX or CygWin, the same can be done with:
Code: Select all
grep -v '^\[Round "?"\]$' input_file > output_file
in order to filter out exactly the [Round "?"] lines.

Cheers,
Sven
User avatar
Sven Schüle
 
Posts: 240
Joined: 26 Sep 2004, 20:19
Location: Berlin, Germany

Re: program to remove the round in a pgn database header

Postby Roy Harper » 11 Feb 2005, 16:46

find /v /i "[round" db1.pgn > db2.pgn

worked just great! :D Thanks to all of you that have replied
all of you are great!
Roy :mrgreen:
Roy Harper
 
Posts: 15
Joined: 13 Nov 2004, 17:52

Re: program to remove the round in a pgn database header

Postby Igor Gorelikov » 14 Feb 2005, 10:37

" 1) "sed" is only available under UNIX, or with CygWin or any other "UNIX emulation" environment on non-UNIX platforms. So I'm not sure whether Roy can use it."

No, you may download sed for Windows at
http://sed.sourceforge.net/grabbag/ssed/sed-3.59.zip (40K)

And it does not require any support library.

"2)-4)"
My previous suggestion was wrong. The right line is as follows:

sed "/Round .?/d" input_file > output_file

Now it deletes all desired lines. Note that inner double quotes are replaced with . (ie any character) due to Windows XP issue.

Best regards,
Igor
User avatar
Igor Gorelikov
 
Posts: 153
Joined: 27 Sep 2004, 10:12
Location: St. Petersburg, Russia


Return to Winboard and related Topics

Who is online

Users browsing this forum: No registered users and 58 guests