I need help editing a pgn file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I need help editing a pgn file
# 8  
Old 11-18-2009
Sorry guys. It seems that my previous posts were leaving out an important fact. Smilie That there is more than one game in every file, also I have hundreds of files. Which can all be processed using a simple for loop. If I can't find a single line awk, sed or perl command I might resort to loading them into my database with utl_file and pl/sql. Both of which are a part of Oracle.

Thanks.

Code:
[Event "8th Asian Continental Women"]
[Site "Subic Bay PHI"]
[Date "2009.05.21"]
[Round "9"]
[White "Zhu Chen"]
[Black "Sachdev,T"]
[Result "1/2-1/2"]
[WhiteElo "2491"]
[BlackElo "2423"]
[ECO "E36"]

1.d4 Nf6 2.c4 e6 3.Nc3 Bb4 4.Qc2 d5 5.a3 Bxc3+ 6.Qxc3 dxc4 7.Qxc4 b6 8.Bf4 Nd5
9.Bg3 O-O 10.Nf3 f5 11.Qc2 Ba6 12.e4 Bxf1 13.Kxf1 fxe4 14.Qxe4 Re8 15.Kg1 Nd7
16.h3 c5 17.dxc5 Nxc5 18.Qe2 Qf6 19.Kh2 Nb3 20.Rad1 Rac8 21.Rhe1 Nc5 22.Rd4 Qf7
23.Qd1 Nd7 24.Rd2 Rc5 25.b4 Rcc8 26.Nd4 Qf6 27.Nxe6 Rxe6 28.Rxd5 Rxe1 29.Qxe1 Nf8
30.Qd1 Re8 31.Rd3 h6 32.Rf3 Qe6 33.Qa4 Re7 34.b5 Qd5 35.Rc3 Qb7 36.Qc4+ Kh7
37.Bd6 Rf7 38.f3 Qd7 39.Rd3 Qe6 40.Qe4+ Kg8 41.Bxf8 Qxe4 42.fxe4 Rxf8 43.Rd7 Rf4
44.Rxa7 Rxe4 45.Ra6 Re6 46.Kg3 Kf7 47.a4 Kf6 48.a5 bxa5 49.Rxa5 Re5 50.Ra6+ Kf5
51.Rb6 Re3+ 52.Kf2 Rb3 53.Rb7 Rb2+ 54.Kg3 Rb3+ 55.Kh2 h5 56.Kg1 Rb2 57.b6 g6
58.Rb8 Kf6 59.Kh2 h4 60.b7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
72.Kc5 Kxd7  0-1

[Event "8th Asian Continental Women"]
[Site "Subic Bay PHI"]
[Date "2009.05.23"]
[Round "11"]
[White "Zhu Chen"]
[Black "Zhang Jilin"]
[Result "1/2-1/2"]
[WhiteElo "2491"]
[BlackElo "2335"]
[ECO "B90"]

1.e4 c5 2.Nf3 d6 3.d4 cxd4 4.Nxd4 Nf6 5.Nc3 a6 6.h3 e5 7.Nde2 b5 8.g4 Bb7
9.Bg2 Be7 10.Ng3 O-O 11.O-O Nbd7 12.Nf5 Nc5 13.Bg5 b4 14.Bxf6 Bxf6 15.Nd5 Bg5
16.a3 bxa3 17.b4 Ne6 18.Nxd6 Bxd5 19.Qxd5 Nf4 20.Qxe5 Ne2+ 21.Kh1 Bf4 22.Qd5 Qxd6
23.Qc4 Nd4 24.Rfd1 Rac8 25.Qxd4 Qxd4 26.Rxd4 Be5 27.Rdd1 Bxa1 28.Rxa1 Rc3
29.e5 Rd8 30.Kg1 Rd4 31.Kf1 g5 32.Ke1 Rdc4 33.Bf1 Rxb4 34.Kd2 Rf3 35.Bd3 Ra4
36.Ra2 Rxh3 37.c4 Ra5 38.Kc3 Rxe5 39.Rxa3 Re8 40.Kc2 Rd8 41.f3 Kg7 42.Bf5 Re8
43.Rc3 Rh2+ 44.Kb3 Rb8+ 45.Ka3 Rh1 46.Ka2 Re1 47.Be4 Re8 48.c5 R1xe4 49.fxe4 Rxe4
50.c6 Re8 51.Kb3 h5 52.gxh5 Kh6 53.Rf3 Re7 54.Kc4 Kxh5 55.Kd5 g4 56.Rf1 g3
57.Kd6 Re2 58.Rxf7 Rd2+ 59.Ke6 Rc2 60.Kd7 Kh4 61.c7 g2 62.Rg7 Kh3 63.c8=Q Rxc8
64.Kxc8 a5 65.Rh7+ Kg3 66.Rg7+ Kf2 67.Rf7+  1/2-1/2

# 9  
Old 11-18-2009
This almost works, but there is a leading space where there should not be one:
Code:
awk '!NF{ORS=(FS==ORS)?"\n":FS}1' infile

# 10  
Old 11-18-2009
This almost works, but there is a leading space where there should not be one:
Code:
awk '!NF{ORS=(FS==ORS)?"\n":FS}1' infile

# 11  
Old 11-18-2009
Quote:
Originally Posted by Scrutinizer
This almost works, but there is a leading space where there should not be one:
Code:
awk '!NF{ORS=(FS==ORS)?"\n":FS}1' infile

Duplicate post Smilie
Code:
awk '!NF{ORS=(ORS==RS)?FS:RS;next}1' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert vi editing to text editing

Dear Guru's I'm using Putty and want to edit a file. I know we generally use vi editor to do it. As I'm not good in using vi editor, I want to convert the vi into something like text pad. Is there any option in Putty to do the same ? Thanks for your response. Srini (6 Replies)
Discussion started by: thummi9090
6 Replies

2. UNIX for Dummies Questions & Answers

File editing

Hi All, I've to edit the below file in the Current File: XXX Rows found with null for one or more non-nullable columns in the source table SELECT COUNT(*) FROM ( SELECT 1 as one FROM datum WHERE:wall: datum.ID IS NULL ) a (1 Reply)
Discussion started by: udayakumar
1 Replies

3. Shell Programming and Scripting

Need help in editing a file

I have a file which has 10 million records in it. When am trying to edit the file with vi, the following error occurs: ~ ~ ~ ~ ~ ~ ~ ~ "file1" Value too large for defined data type Is there any way that I can edit this file without using vi? Any help would be really appreciated.... (8 Replies)
Discussion started by: bobby1015
8 Replies

4. Shell Programming and Scripting

editing line in text file adding number to value in file

I have a text file that has data like: Data "12345#22" Fred ID 12345 Age 45 Wilma Dino Data "123#22" Tarzan ID 123 Age 33 Jane I need to figure out a way of adding 1,000,000 to the specific lines (always same format) in the file, so it becomes: Data "1012345#22" Fred ID... (16 Replies)
Discussion started by: say170
16 Replies

5. Shell Programming and Scripting

Help with file editing while keeping file format intact

Hi, I am having a file which is fix length and comma seperated. And I want to replace values for one column. I am reading file line by line in variable $LINE and then replacing the string. Problem is after changing value and writing new file temp5.txt, formating of original file is getting... (8 Replies)
Discussion started by: Mruda
8 Replies

6. Shell Programming and Scripting

editing a file

i am writing a script to edit entries in a file. what command will edit a specific file? ex: echo) "what number would you like to change read "number" this is where I am stuck. what command will edit my specific file? (3 Replies)
Discussion started by: gustave
3 Replies

7. Shell Programming and Scripting

editing a file

Hi i have a file name as file1 which has Following content: ROLLOVER_INTERVAL=0 OUTPUT_DIR_COUNT=MULTIPLE FILETYPE=XmlExporter i want to change the FILETYPE=recordexport can any one pls help me on this 2nd query: i want to change OUTPUT_DIR_COUNT=MULTIPLE as ... (2 Replies)
Discussion started by: Aditya.Gurgaon
2 Replies

8. Linux

file editing

I have created a file with vi -x (file name) this is encrypted file when i again open this file it ask me to enter a password before editing it.Can i remove this password but i don't want to delete a file how to do this. Thanks (0 Replies)
Discussion started by: ambavaram
0 Replies

9. Shell Programming and Scripting

Editing file

Hi, I am in a situation wherein am getting file file certailn values suppose 1u56979hhghhklklkkkjkjkjk 0 0 0 The file will have values like above only. I need to add another field of NULL value(of length 9) at the end of first column i.e. It should like this after editing:... (4 Replies)
Discussion started by: rahul303
4 Replies

10. UNIX for Advanced & Expert Users

Editing the end of the file without loading the entire file

hi! I am a newbee. I would really appreciate if you can answer the following question: I have a huge data file, 214MB with several coloumns. I need to delete the very last line of the file. Everything I know takes a lot of time to do it ( because I have to open the file in an editor or run a... (3 Replies)
Discussion started by: Garuda
3 Replies
Login or Register to Ask a Question