Skip to content

Instantly share code, notes, and snippets.

@Reino17
Created September 7, 2023 14:07
Show Gist options
  • Select an option

  • Save Reino17/468f9ceed9822332c79e48e7f9eee274 to your computer and use it in GitHub Desktop.

Select an option

Save Reino17/468f9ceed9822332c79e48e7f9eee274 to your computer and use it in GitHub Desktop.
Turn the "Men's records"-table into "|"-separated values and white-space aligned columns
Turn the "Men's records"-table into "|"-separated values:
$ xidel -s "https://en.wikipedia.org/wiki/List_of_Olympic_records_in_athletics" -e '
(//table)[1]/tbody/tr/join(
(td|th) ! normalize-space( (: For every text-node remove the :)
join(.//text() ! replace(.," ","")) (: no-break-spaces, string-join :)
), (: them together and remove :)
" | " (: excessive white-space. :)
)
'
Event | Record | Athlete(s) | Nation | Games | Date | Ref(s)
100 metres | 9.63 | Usain Bolt | Jamaica (JAM) | 2012 London | August 5, 2012 | [9]
200 metres | 19.30 | Usain Bolt | Jamaica (JAM) | 2008 Beijing | August 20, 2008 | [10]
400 metres | ♦43.03 | Wayde van Niekerk | South Africa (RSA) | 2016 Rio de Janeiro | August 14, 2016 | [11]
800 metres | ♦1:40.91 | David Rudisha | Kenya (KEN) | 2012 London | August 9, 2012 | [12]
1,500 metres | 3:28.32 | Jakob Ingebrigtsen | Norway (NOR) | 2020 Tokyo | August 7, 2021 | [13]
5,000 metres | 12:57.82 | Kenenisa Bekele | Ethiopia (ETH) | 2008 Beijing | August 23, 2008 | [14]
10,000 metres | 27:01.17 | Kenenisa Bekele | Ethiopia (ETH) | 2008 Beijing | August 17, 2008 | [15]
Marathon | 2:06:32 | Samuel Wanjiru | Kenya (KEN) | 2008 Beijing | August 24, 2008 | [16]
110 metres hurdles | 12.91 | Liu Xiang | China (CHN) | 2004 Athens | August 27, 2004 | [17]
400 metres hurdles | ♦45.94 | Karsten Warholm | Norway (NOR) | 2020 Tokyo | August 3, 2021 | [18]
3,000 m steeplechase | 8:03.28 | Conseslus Kipruto | Kenya (KEN) | 2016 Rio de Janeiro | August 17, 2016 | [19]
4×100 m relay | ♦36.84 | Nesta Carter Michael Frater Yohan Blake Usain Bolt | Jamaica (JAM) | 2012 London | August 11, 2012 | [20]
4×400 m relay | 2:55.39 | LaShawn Merritt Angelo Taylor David Neville Jeremy Wariner | United States (USA) | 2008 Beijing | August 23, 2008 | [21]
20 km walk | 1:18:46 | Chen Ding | China (CHN) | 2012 London | August 4, 2012 | [22]
50 km walk | 3:36:53 | Jared Tallent | Australia (AUS) | 2012 London | August 11, 2012 | [23]
High jump | 2.39m | Charles Austin | United States (USA) | 1996 Atlanta | July 28, 1996 | [24]
Long jump | 8.90m | Bob Beamon | United States (USA) | 1968 Mexico City | October 18, 1968 | [6]
Pole vault | 6.03m | Thiago Braz | Brazil (BRA) | 2016 Rio de Janeiro | August 15, 2016 | [25]
Triple jump | 18.09m | Kenny Harrison | United States (USA) | 1996 Atlanta | July 27, 1996 | [26]
Shot put | 23.30m | Ryan Crouser | United States (USA) | 2020 Tokyo | August 5, 2021 | [27]
Discus throw | 69.89m | Virgilijus Alekna | Lithuania (LTU) | 2004 Athens | August 23, 2004 | [28]
Hammer throw | 84.80m | Sergey Litvinov | Soviet Union (URS) | 1988 Seoul | September 26, 1988 | [29]
Javelin throw | 90.57m | Andreas Thorkildsen | Norway (NOR) | 2008 Beijing | August 23, 2008 | [30]
Decathlon | 9018pts | Damian Warner | Canada (CAN) | 2020 Tokyo | August 5, 2021 | [31]
================================================================================================================================
Turn the "Men's records"-table into white-space aligned columns:
$ xidel -s "https://en.wikipedia.org/wiki/List_of_Olympic_records_in_athletics" -e '
let $l:=(//table)[1]/tbody/tr/array{
(td|th) ! normalize-space( (: Return the string-length of :)
join(.//text() ! replace(.," ","")) (: every item in a first pass. :)
) ! string-length()
}
return
$l
'
[5, 6, 10, 6, 5, 4, 6]
[10, 4, 10, 13, 11, 14, 3]
[10, 5, 10, 13, 12, 15, 4]
[10, 6, 17, 18, 19, 15, 4]
[10, 8, 13, 11, 11, 14, 4]
[12, 7, 18, 12, 10, 14, 4]
[12, 8, 15, 14, 12, 15, 4]
[13, 8, 15, 14, 12, 15, 4]
[8, 7, 14, 11, 12, 15, 4]
[18, 5, 9, 11, 11, 15, 4]
[18, 6, 15, 12, 10, 14, 4]
[20, 7, 17, 11, 19, 15, 4]
[13, 6, 50, 13, 11, 15, 4]
[13, 7, 58, 19, 12, 15, 4]
[10, 7, 9, 11, 11, 14, 4]
[10, 7, 13, 15, 11, 15, 4]
[9, 5, 14, 19, 12, 13, 4]
[9, 5, 10, 19, 16, 16, 3]
[10, 5, 11, 12, 19, 15, 4]
[11, 6, 14, 19, 12, 13, 4]
[8, 6, 12, 19, 10, 14, 4]
[12, 6, 17, 15, 11, 15, 4]
[12, 6, 15, 18, 10, 18, 4]
[13, 6, 19, 12, 12, 15, 4]
[9, 7, 13, 12, 10, 14, 4]
$ xidel -s "https://en.wikipedia.org/wiki/List_of_Olympic_records_in_athletics" -e '
let $l:=(//table)[1]/tbody/tr/array{
(td|th) ! normalize-space( (: Return the string-length of :)
join(.//text() ! replace(.," ","")) (: every item in a first pass. :)
) ! string-length() (: From this sequence of arrays :)
}, (: return the highest number of :)
$l_max:=(1 to count($l[1]()) - 1) ! max($l(.)) (: every position but the last. :)
return
array{$l_max}
'
[20, 8, 58, 19, 19, 18]
$ xidel -s "https://en.wikipedia.org/wiki/List_of_Olympic_records_in_athletics" -e '
let $l:=(//table)[1]/tbody/tr/array{
(td|th) ! normalize-space( (: Return the string-length of :)
join(.//text() ! replace(.," ","")) (: every item in a first pass. :)
) ! string-length() (: From this sequence of arrays :)
}, (: return the highest number of :)
$l_max:=(1 to count($l[1]()) - 1) ! max($l(.)) (: every position but the last. :)
return
(//table)[1]/tbody/tr/string-join( (: Add the needed white-space :)
for $x at $i in (td|th) ! normalize-space( (: while string-joining all items :)
join(.//text() ! replace(.," ","")) (: together in a second pass. :)
) return (
$x,
(1 to $l_max[$i] - string-length($x) + 2) ! " "
)
)
' > List_of_Olympic_records_in_athletics.txt
$ xidel -s "List_of_Olympic_records_in_athletics.txt" -e '$raw'
Event Record Athlete(s) Nation Games Date Ref(s)
100 metres 9.63 Usain Bolt Jamaica (JAM) 2012 London August 5, 2012 [9]
200 metres 19.30 Usain Bolt Jamaica (JAM) 2008 Beijing August 20, 2008 [10]
400 metres ♦43.03 Wayde van Niekerk South Africa (RSA) 2016 Rio de Janeiro August 14, 2016 [11]
800 metres ♦1:40.91 David Rudisha Kenya (KEN) 2012 London August 9, 2012 [12]
1,500 metres 3:28.32 Jakob Ingebrigtsen Norway (NOR) 2020 Tokyo August 7, 2021 [13]
5,000 metres 12:57.82 Kenenisa Bekele Ethiopia (ETH) 2008 Beijing August 23, 2008 [14]
10,000 metres 27:01.17 Kenenisa Bekele Ethiopia (ETH) 2008 Beijing August 17, 2008 [15]
Marathon 2:06:32 Samuel Wanjiru Kenya (KEN) 2008 Beijing August 24, 2008 [16]
110 metres hurdles 12.91 Liu Xiang China (CHN) 2004 Athens August 27, 2004 [17]
400 metres hurdles ♦45.94 Karsten Warholm Norway (NOR) 2020 Tokyo August 3, 2021 [18]
3,000 m steeplechase 8:03.28 Conseslus Kipruto Kenya (KEN) 2016 Rio de Janeiro August 17, 2016 [19]
4×100 m relay ♦36.84 Nesta Carter Michael Frater Yohan Blake Usain Bolt Jamaica (JAM) 2012 London August 11, 2012 [20]
4×400 m relay 2:55.39 LaShawn Merritt Angelo Taylor David Neville Jeremy Wariner United States (USA) 2008 Beijing August 23, 2008 [21]
20 km walk 1:18:46 Chen Ding China (CHN) 2012 London August 4, 2012 [22]
50 km walk 3:36:53 Jared Tallent Australia (AUS) 2012 London August 11, 2012 [23]
High jump 2.39m Charles Austin United States (USA) 1996 Atlanta July 28, 1996 [24]
Long jump 8.90m Bob Beamon United States (USA) 1968 Mexico City October 18, 1968 [6]
Pole vault 6.03m Thiago Braz Brazil (BRA) 2016 Rio de Janeiro August 15, 2016 [25]
Triple jump 18.09m Kenny Harrison United States (USA) 1996 Atlanta July 27, 1996 [26]
Shot put 23.30m Ryan Crouser United States (USA) 2020 Tokyo August 5, 2021 [27]
Discus throw 69.89m Virgilijus Alekna Lithuania (LTU) 2004 Athens August 23, 2004 [28]
Hammer throw 84.80m Sergey Litvinov Soviet Union (URS) 1988 Seoul September 26, 1988 [29]
Javelin throw 90.57m Andreas Thorkildsen Norway (NOR) 2008 Beijing August 23, 2008 [30]
Decathlon 9018pts Damian Warner Canada (CAN) 2020 Tokyo August 5, 2021 [31]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment