davesmith202
Employee of Access World
- Local time
- Today, 16:59
- Joined
- Jul 20, 2001
- Messages
- 522
I want to create a routine that looks at a text file and parses the contents into fields in a database. It is based on the PGN chess file format.
There would be an Event field, Date field etc. and of course the Moves field.
Sample data:
It could also look like this:
Any suggestions on how to do this? Can't get my head around it!
Sometimes it will have all the headers, sometimes not. It will always have all the moves. But sometimes the moves are as a continuous line, other times they are like in the first example where there are line breaks.
Anyone want to take a stab at this one?
Thanks,
Dave
There would be an Event field, Date field etc. and of course the Moves field.
Sample data:
[Event "St George's CC"]
[Site "St George's CC"]
[Date "1856.??.??"]
[Round "?"]
[White "Wywill, Marmaduke"]
[Black "Lowenthal"]
[Result "0-1"]
[ECO "A03"]
[PlyCount "76"]
[EventDate "1856.??.??"]
1. f4 d5 2. Nf3 Nc6 3. e3 Bg4 4. Bb5 e6 5. O-O Bd6 6. b3 Nge7 7. Bb2 O-O 8. c4
dxc4 9. bxc4 e5 10. c5 Bxc5 11. fxe5 Bxf3 12. Rxf3 Nd4 13. Rh3 Nxb5 14. Qc2
Bxe3+ 15. dxe3 h6 16. Nd2 c6 17. Ne4 Ng6 18. e6 Qe8 19. Rxh6 Qxe6 20. Nf6+ gxf6
21. Rxg6+ fxg6 22. Qxg6+ Kh8 23. Qh6+ Kg8 24. Rf1 Rae8 25. Qg6+ Kh8 26. Rxf6
Qxe3+ 27. Rf2+ Nd4 28. Qh5+ Kg7 29. Qg4+ Kh6 30. Qh4+ Kg6 31. Qg4+ Qg5 32.
Qxg5+ Kxg5 33. Rxf8 Rxf8 34. Bxd4 b6 35. Be3+ Kf5 36. Kf2 Ke4+ 37. Ke2 Rh8 38.
Bg1 Rh4 0-1
[Event "Vienna"]
[Site "Vienna"]
[Date "1873.??.??"]
[Round "1"]
[White "Bird, Henry"]
[Black "Heral, Joseph"]
[Result "0-1"]
[ECO "A03"]
[PlyCount "106"]
[EventDate "1873.??.??"]
1. f4 d5 2. Nf3 Nc6 3. e3 Nf6 4. b3 Bg4 5. Be2 Bxf3 6. Bxf3 e6 7. c3 Bd6 8. d4
Ne7 9. Na3 a6 10. O-O c6 11. Nc2 Qc7 12. c4 Qb8 13. Bb2 h6 14. Qd3 g5 15. g3 g4
16. Bg2 h5 17. e4 Bc7 18. e5 Nd7 19. Ne3 Qa7 20. cxd5 cxd5 21. Kh1 O-O-O 22. f5
Bb6 23. a3 Nxe5 24. dxe5 Bxe3 25. fxe6 h4 26. gxh4 fxe6 27. Rae1 Bb6 28. Rf6
Rxh4 29. Bc1 Rdh8 30. Bf4 Bf2 31. Rf1 g3 32. Bxg3 Bxg3 33. Rf8+ Kd7 34. Rxh8
Rxh8 35. Qxg3 Qd4 36. Qg5 Qh4 37. Qxh4 Rxh4 38. Bf3 Nc6 39. Re1 Nd4 40. Bd1 Kc6
41. Kg2 Kc5 42. Re3 Nf5 43. Re1 Kd4 44. Bf3 Kc3 45. h3 b5 46. Bg4 d4 47. Bxf5
It could also look like this:
[Event "A30-c4,c5,Nf3"]
[Site "chessopeningsdatabase.com"]
[Date "1996"]
[Round "1"]
[White "kortschnoi v"]
[Black "brunner lucas"]
[Result "1-0"]
[ECO "A30"]
[PlyCount "75"]
1. c4 c5 2. Nf3 Nf6 3. Nc3 e6 4. g3 d5 5. cxd5 Nxd5 6. Bg2 Nc6 7. O-O Be7 8. d4 O-O 9. e4 Nb6 10. dxc5 Qxd1 11. Rxd1 Bxc5 12. Bf4 f6 13. Rac1 e5 14. Nb5 exf4 15. Rxc5 fxg3 16. hxg3 Bg4 17. Rd2 Rad8 18. Nd6 Bxf3 19. Bxf3 Rf7 20. Bg4 Re7 21. f4 Kf8 22. a3 g6 23. Bh3 Rc7 24. Rcc2 a6 25. Kg2 Ke7 26. e5 fxe5 27. fxe5 Na8 28. Rf2 Nxe5 29. Rxc7+ Nxc7 30. Nc8+ Rxc8 31. Bxc8 b6 32. Rd2 a5 33. b3 h5 34. Kf2 g5 35. Ke3 a4 36. Ke4 Nf7 37. Rd7+ Ke8 38. Rxc7 1-0
[Event "A30-c4,c5,Nf3"]
[Site "chessopeningsdatabase.com"]
[Date "1995"]
[Round "1"]
[White "koolsbergen nico"]
[Black "powles jonathan"]
[Result "0-1"]
[ECO "A30"]
[PlyCount "114"]
1. c4 c5 2. Nf3 Nf6 3. g3 b6 4. Bg2 Bb7 5. O-O e6 6. Nc3 Be7 7. b3 O-O 8. d4 cxd4 9. Qxd4 Nc6 10. Qd1 d5 11. cxd5 exd5 12. Bf4 Qd7 13. a3 d4 14. Nb5 Rfd8 15. Qd3 a6 16. Nc7 Ra7 17. Ng5 Bd6 18. Nd5 Bxf4 19. Nxf4 Ne5 20. Qb1 Bxg2 21. Kxg2 Rc7 22. Nh5 Qd5+ 23. Kg1 Neg4 24. Nxf6+ Nxf6 25. Nf3 Ne4 26. Qd3 Rc3 27. Qxa6 d3 28. Rad1 d2 29. b4 Qc6 30. e3 Rc1 31. Kg2 f6 32. b5 Qc7 33. Qa4 Qc2 34. Qxc2 Rxc2 35. Nd4 Ra2 36. Ne2 Rxa3 37. Kf3 Nc5 38. Rb1 Ra2 39. Rfd1 Na4 40. Rh1 Rb2 41. Ra1 Rxb5 42. Nd4 Nc3 43. Nxb5 Nxb5 44. Rhd1 Nc3 45. Kf4 b5 46. e4 Rd3 47. h4 b4 48. e5 fxe5+ 49. Kxe5 b3 50. Ra8+ Kf7 51. Ra7+ Kg6 52. h5+ Kh6 53. Ra6+ Kxh5 54. Rh1+ Kg4 55. Rb6 d1=Q 56. Rxd1 Nxd1 57. Rb7 g5 0-1
Any suggestions on how to do this? Can't get my head around it!
Sometimes it will have all the headers, sometimes not. It will always have all the moves. But sometimes the moves are as a continuous line, other times they are like in the first example where there are line breaks.
Anyone want to take a stab at this one?
Thanks,
Dave