PDA

View Full Version : PGN to Word without line breaks



Kevin Bonham
27-01-2010, 10:05 PM
Could have saved myself lots of time with Aus Junior bulletins if I'd known the answer (if there is one) to this:

When one copies and pastes PGN format into Word set up into narrow columns, the PGN comes out with line breaks all through it, resulting in a lot of short lines in the text rather than the text of moves wrapping to the columns. Is there an easy way to get rid of the line breaks without manually deleting them?

Ian Rout
28-01-2010, 08:25 AM
Could have saved myself lots of time with Aus Junior bulletins if I'd known the answer (if there is one) to this:

When one copies and pastes PGN format into Word set up into narrow columns, the PGN comes out with line breaks all through it, resulting in a lot of short lines in the text rather than the text of moves wrapping to the columns. Is there an easy way to get rid of the line breaks without manually deleting them?
From memory (don't have it with me) if you use the Output function in Chessbase (to RTF, possibly not true for TXT) it doesn't put line breaks into the moves.

If whatever reason the line breaks are already there, for instance you don't have CB or the line breaks are there from previous handling, a quicker way than deleting them individually is to note that Word stores line breaks by the sequence ^p so you can globally replace ^p with a space.

That means you will replace some line breaks you want to keep so either mark the games one at a time, or in some instances you can first replace ^p^p (double line break) with some odd sequence then put them back afterwards; still some cleaning up afterwards but generally these strategies are quicker than deleting line breaks one by one.

Z&MLoh
28-01-2010, 09:45 AM
Steps to replace the line breaks or paragraphs marks in Word are:
1. Highlight text pasted in Word
2. Select Replace in Edit menu
3. Click "More" button in bottom of dialog box
4. Click "Special" button in the bottom of the dialog box
5. Click "paragraph mark" in the pop up menu. (^p then appears in "Find What:" box). Alternatively, steps 3-5 can be replaced by typing ^p in the "Find What" box.
6. Click "Replace All" button or "Replace" to do it instance by instance.
7. Dialog box pops up with the phrase "Word has finished searching .... Do you want to search the remainder of the document?". Click "No" unless you want to search the rest of the document.
8. Close Replace dialog box.

Note: My version of Word is old - Word 2002 so the button and menu locations may be different.


Mike

Jesper Norgaard
28-01-2010, 10:44 AM
I have a solution that might interest you, because it might save steps compared to the others. I use the Postcardware program Editpad (by Jan Goyvaerts)

To summarize, I believe you have a PGN file with the following psedo-format

[Player1]
[Player2]
[Event]
1.e4 e5 2.Nf3 Nf6
3.Nxe5 1-0

You want to remove all line breaks except the ones between each game and after each item (like Player1).

To remove line break you ask to replace "\n" with "" (don't actually write the apostrophes!). Here is the list of replaces you need to do:

Replace "\n\n" with ""
Replace "]\n" with "]"
Replace "\n" with ""
Replace "" with "\n" {to get back the original line breaks that you wanna keep}

Done! Sounds simple, right? I hope it will be. I haven't actually tried it, but you might figure it out if there are flaws in my instructions.

Z&MLoh
28-01-2010, 04:13 PM
Great idea and you can do in Word as well.

1. Highlight all the text pasted in Word including the text in the square brackets.
2. Select Replace in Edit menu
3. In the "Find What:" text box type "]^p" and in the "Replace With" text box type "]]" (or anything that doesn't appear in the text). Click "Replace All" button. This step to separate line breaks for text in square brackets.
4. Select Replace in Edit menu again
5. In the "Find What:" text box type "^p" and click "Replace All" button. Delete all text (if any) in the "Replace With" text box. This step to remove line breaks in the chess moves.
6. Select Replace in Edit menu one last time
7. In the "Find What:" text box, replace "]]" and and in the "Replace With" text box type "^p". Then click "Replace All" button. This step to restore the line breaks for the text in the square brackets.

Jesper Norgaard
29-01-2010, 06:23 AM
7. In the "Find What:" text box, replace "]]" and and in the "Replace With" text box type "^p". Then click "Replace All" button. This step to restore the line breaks for the text in the square brackets.
I think it needs to be Replace with "]^p" or else the right brackets will be gone forever. :eek: