Here is a collection of scripts which I used in sed to assist with some articles. I use sed under Windows. Scripts can be easily adapted for Linux users, it is probably not difficult to adapt them for usage with other tools based on regular expressions.

WTA statistics

edit

Example usage

edit

Input

edit

I copy the data from the pdf-file on the WTA site http://www.wtatennis.com/SEWTATour-Archive/Rankings_Stats/match_stats_2015.pdf to get the following file and name it aces.txt. I add the newline at the end.

1 PLISKOVA , KAROLINA 53 7
2 KVITOVA , PETRA 48 8
3 ZAHLAVOVA STRYCOVA , B 33 7
4 MUGURUZA , GARBINE 27 3
5 WILLIAMS , VENUS 26 5
6 VANDEWEGHE , COCO 24 3
7 IVANOVIC , ANA 23 4
8 WATSON , HEATHER 23 5
9 GOERGES , JULIA 22 3
10 KEYS , MADISON 22 4

Output

edit

After running urobaces.bat I get the file which renders like this. (I have to remove extra char added at the end of file when joinging the files together.)

EDIT: I don't know why the table does not render here and is placed at the bottom of the page instead, but the same code works fine here.

ACES
# Player Aces Matches
1   Karolína Plíšková 53 7
2   Petra Kvitova 48 8
3   Barbora Záhlavová-Strýcová 33 7
4   Garbine Muguruza 27 3
5   Venus Williams 26 5
6   Coco Vandeweghe 24 3
7   Ana Ivanovic 23 4
8   Heather Watson 23 5
9   Julia Görges 22 3
10   Madison Keys 22 4

Scripts

edit

I put the scripts also on my website: http://msleziak.com/temp/wiki/001stats.zip

urobaces.bat:

call sedpath
sed -f mena.sed aces.txt > aces1.txt
sed -f pom.sed aces1.txt > aces2.txt
sed -f parne.sed aces2.txt > aces3.txt
sed -f newline.sed aces3.txt > aces4.txt
sed -f names.sed aces4.txt > aces5.txt
sed -f center.sed aces5.txt > aces6.txt
copy acesstart.txt+aces6.txt+acesend.txt acesout.txt

mena.sed and names.sed: these files have to be made manually
mena.sed:

s/GOERGES , JULIA/GOERGESJULIA/
s/IVANOVIC , ANA/IVANOVICANA/
s/KEYS , MADISON/KEYSMADISON/
s/KVITOVA , PETRA/KVITOVAPETRA/
s/MUGURUZA , GARBINE/MUGURUZAGARBINE/
s/PLISKOVA , KAROLINA/PLISKOVAKAROLINA/
s/VANDEWEGHE , COCO/VANDEWEGHECOCO/
s/WATSON , HEATHER/WATSONHEATHER/
s/WILLIAMS , SERENA/WILLIAMSSERENA/
s/WILLIAMS , VENUS/WILLIAMSVENUS/
s/ZAHLAVOVA STRYCOVA , B/ZAHLAVOVASTRYCOVAB/

names.sed:

s/GOERGESJULIA/  Julia Görges/
s/IVANOVICANA/  Ana Ivanovic/
s/KEYSMADISON/  Madison Keys/
s/KVITOVAPETRA/  Petra Kvitova/
s/MUGURUZAGARBINE/  Garbine Muguruza/
s/PLISKOVAKAROLINA/  Karolína Plíšková/
s/VANDEWEGHECOCO/  Coco Vandeweghe/
s/WATSONHEATHER/  Heather Watson/
s/WILLIAMSSERENA/  Serena Williams/
s/WILLIAMSVENUS/  Venus Williams/
s/ZAHLAVOVASTRYCOVAB/  Barbora Záhlavová-Strýcová/

pom.sed:

s/^/|-|/
s/ /|/
s/ /|/
s/ /|CENTER/

parne.sed:

1 s/|-|/|- style="background:#FFF0F5;"|/
3 s/|-|/|- style="background:#FFF0F5;"|/
5 s/|-|/|- style="background:#FFF0F5;"|/
7 s/|-|/|- style="background:#FFF0F5;"|/
9 s/|-|/|- style="background:#FFF0F5;"|/

newline.sed:

s/|\([^-]\)/\n|\1/g

center.sed:

s/CENTER/align=center|/

Tennis draws

edit

I have made some scripts which take to partially automatize creation of a draw for tennis tournament (and filling in players' names, but not results). I will copy it here when I have more time.