Page 1 of 1

program to remove the round in a pgn database header

PostPosted: 11 Feb 2005, 03:39
by Roy Harper
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

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

PostPosted: 11 Feb 2005, 03:52
by Michael Yee
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".

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

PostPosted: 11 Feb 2005, 04:20
by Roy Harper
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.

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

PostPosted: 11 Feb 2005, 09:17
by Tim Foden
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.

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

PostPosted: 11 Feb 2005, 11:05
by Igor Gorelikov
You can do dit with sed:

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

Better use the batch file with this line.
Igor

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

PostPosted: 11 Feb 2005, 15:07
by Sven Schüle
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

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

PostPosted: 11 Feb 2005, 16:46
by Roy Harper
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:

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

PostPosted: 14 Feb 2005, 10:37
by Igor Gorelikov
" 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