User:Kompik/scripts/sed
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
Example usage
Input
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
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 | 53 | 7 | |
| 2 | 48 | 8 | |
| 3 | 33 | 7 | |
| 4 | 27 | 3 | |
| 5 | 26 | 5 | |
| 6 | 24 | 3 | |
| 7 | 23 | 4 | |
| 8 | 23 | 5 | |
| 9 | 22 | 3 | |
| 10 | 22 | 4 | |
Scripts
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
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.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.