Tips für eine Nummerierung gesucht

Hallo,
ich suche einen TextEditor der nichts kostet aber richtig etwas kann…
Folgendes habe ich, ein Datensatz endet immer mit einem “*”

[Event “Schach - Matt #1”]
[Site “”]
[Date “2015.06.17”]
[Round “-”]
[White “SkobyMobil”]
[Black “Laszlo Polgar”]
[Result “*”]
[FEN “3q1rk1/5pbp/5Qp1/8/8/2B5/5PPP/6K1 w - - 0 1”]

[Event “Schach - Matt #1”]
[Site “”]
[Date “2015.06.17”]
[Round “-”]
[White “SkobyMobil”]
[Black “Laszlo Polgar”]
[Result “*”]
[FEN “2r2rk1/2q2p1p/6pQ/4P1N1/8/8/PPP5/2KR4 w - - 0 1”]

[Event “Schach - Matt #1”]
[Site “”]
[Date “2015.06.17”]
[Round “-”]
[White “SkobyMobil”]
[Black “Laszlo Polgar”]
[Result “*”]
[FEN “r2q1rk1/pp1p1p1p/5PpQ/8/4N3/8/PP3PPP/R5K1 w - - 0 1”]

Hier sind es jetzt 3 Datensätze, ich habe hier 5334 Datensätze.
In jedem Datensatz gibt es:
[Round “-”]

Ich möchte nun den Bindestrich “-” durch eine Nummerierung ersetzen:
[Round “001”]
[Round “002”]
[Round “003”]

Hat jemand einen Tip für mich?
Gruß und Spaß
Andreas

Mach mal Dein Terminal auf. Wir tun mal so, dass die Datei “skoby.txt” heißt. Dann gehst Du mit “cd” in das Verzeichnis, wo die Datei liegt, und schickst das hier ab:

cat skoby.txt |awk '{ if ($1 == "[Round") {count++; $2="\""count"\""; print $0 "]"} else print $0}'

…funktionieren tut das nur korrekt, wenn in jedem Datensatz nur ein [Round “-”] Eintrag ist. Wäre das was? Einen Editor wirst Du mMn nicht finden, der sowas kann - dafür bräuchte man Reguläre Ausdrücke, die in Variablen rechnen könnten…

Falls der Befehl oben tut, hängst Du hinten noch ein >skoby2.txt an, und schon hast Du das in einer neuen Datei…

1 „Gefällt mir“

Hey,

ich hab zwar keinen Texteditor aber ich hab mal ganz quick and dirty ne Webseite geschrieben, die dir alle [Round “-”] ersetzt durch Round[0001] usw.
Ich nehm einfach mal an, dass du die Daten als .txt hast.
Geht aber nur bis 9.999, dann würde er wieder bei 0 anfangen ^^

Ersetzer Webseite

Hier ist auch noch der Code, falls du es dir selber speichern willst und lokal ausführen:

[code]

Ersetzer
[/code]

Edit: Mist, da war Joerg schneller. Hätte die Seite doch mal neuladen sollen vor dem Abschicken :smiley:

1 „Gefällt mir“

Hallo Jörg,
ich habe das im Terminal vorher schon probiert, bin aber nicht drauf gekommen.
Hier nun, was DU angestellt hast:

[Event “#5332 Chess: 5334 Problems, Combinations, and Games by L?szl? Polg?r”]
[Site “Copyright 1994 K?nemann”]
[Date “1994.??.??”]
[Round “5333”]
[White “Polgar sisters’ tournament-game combinations”]
[Black “Black to move and win”]
[Result “0-1”]
[FEN “r4r2/p2bp1kp/3pq1p1/2p5/2P1p3/1N4PP/PP1QPPK1/2R4R b - - 0 1”]

1…Rxf2+ 2.Kxf2 e3+ 3.Qxe3 Rf8+ 4.Qf3 Bc6 5.Qxf8+ Kxf8 6.Rhf1 Ke8 7.Rc3
Qf5+ 8.Ke1 Qb1+ 9.Kf2 Qf5+ 10.Ke1 Qxh3 11.Nd2 Bg2 12.Rf2 Qh1+ 13.Nf1 h5
14.e3 Bxf1 15.Rxf1 Qg2 16.Rb3 Qxg3+ 17.Ke2 h4 18.Rb8+ Kd7 19.Rh8 g5 20.
Rff8 Qg4+ 21.Kd3 Qd1+ 22.Kc3 Qc1+ 23.Kd3 Qxb2 24.Rd8+ Ke6 25.Rh6+ Kf5 0-1

[Event “#5333 Chess: 5334 Problems, Combinations, and Games by L?szl? Polg?r”]
[Site “Copyright 1994 K?nemann”]
[Date “1994.??.??”]
[Round “5334”]
[White “Polgar sisters’ tournament-game combinations”]
[Black “Black to move and win”]
[Result “0-1”]
[FEN “3r1r1k/pp4b1/2p5/4p3/2P1Ppbq/1QN2P2/PP4P1/3RRNK1 b - - 0 1”]

1…Bxf3 2.gxf3 Rg8 3.Nh2 Bf8+ 4.Kh1 Bc5 5.Re2 Rd7 6.Na4 Bf2 0-1

[Event “#5334 Chess: 5334 Problems, Combinations, and Games by L?szl? Polg?r”]
[Site “Copyright 1994 K?nemann”]
[Date “1994.??.??”]
[Round “5335”]
[White “Polgar sisters’ tournament-game combinations”]
[Black “White to move (Mate in two)”]
[Result “1-0”]
[FEN “8/2N1K1N1/2pP1Pp1/2P1k1P1/2r1P1r1/2P3P1/4R2B/Q7 w - - 0 1”]

1.Qb2 1-0

das ist allererstesahne gewesen.
Andreas sagt Danke schön.
Gruß und Spaß
Andreas

Hallo Thermite,
ich habe es probiert, Nummerierung formatiert. Das schlägt ja fast alles.
Schau, was Du angestellt hast:

[Event “#97 Chess: 5334 Problems, Combinations, and Games by L·szlÛ Polg·r”]
[Site “Copyright 1994 Kˆnemann”]
[Date “1994.??.??”]
[Round “0098”]
[White “Mate in one”]
[Black “White to move”]
[Result “*”]
[FEN “5Q2/8/8/8/6p1/8/2NNk3/2K5 w - - 0 1”]

1.Qf1# *

[Event “#98 Chess: 5334 Problems, Combinations, and Games by L·szlÛ Polg·r”]
[Site “Copyright 1994 Kˆnemann”]
[Date “1994.??.??”]
[Round “0099”]
[White “Mate in one”]
[Black “White to move”]
[Result “*”]
[FEN “1Q6/8/2K5/3N4/4k3/5N2/6P1/8 w - - 0 1”]

1.Qb1# *

[Event “#99 Chess: 5334 Problems, Combinations, and Games by L·szlÛ Polg·r”]
[Site “Copyright 1994 Kˆnemann”]
[Date “1994.??.??”]
[Round “0100”]
[White “Mate in one”]
[Black “White to move”]
[Result “*”]
[FEN “K7/8/6N1/5n2/4k3/3n4/2N5/Q7 w - - 0 1”]

1.Qh1# *

[Event “#100 Chess: 5334 Problems, Combinations, and Games by L·szlÛ Polg·r”]
[Site “Copyright 1994 Kˆnemann”]
[Date “1994.??.??”]
[Round “0101”]
[White “Mate in one”]
[Black “White to move”]
[Result “*”]
[FEN “8/8/8/8/8/3NkN2/Q7/4K3 w - - 0 1”]

1.Qe2# *

Das ist allerallererstesahne.
Andreas sagt Danke schön.

Nochmals- Vielen Dank für eure Hilfe.
Gruß und Spaß
Andreas
P.S. Code habe ich mir kopiert

Nett - Thermites Lösung ist bequemer. Dafür ist meins ein Einzeiler… ;D

Skoby, die Fehler mit den Umlauten bzw. anderen Sonderzeichen sind beim Rüberkopieren entstanden, oder machen die Lösungen da jeweils was kaputt?

Hallo Jörg,
ich nehme das Terminal, da weiß ich was es “macht”.
Die Umlaute und der andere Dreck stecken in der Datei. Da hat jemand das Format “Timbuktu”
gewählt. Die Datei ist dank eurer Hilfe jetzt aber MacLike u.a.
Zur Info, es sind diese Schachdiagramme an denen ich gefummelt habe.
Ist aber schon ein Hammer, den Thermite da zusammen gekritzelt hat. :yeah:
Gruß und Dank
Andreas