Created
June 6, 2022 09:02
-
-
Save ciscou/c69609575a3116291b02a52515a78e4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# before running, download and unzip the latest TSV export from https://www.worldcubeassociation.org/results/misc/export.html | |
# usage: cat WCA_export_Results.tsv | ruby spanish_podia.rb | |
s = gets | |
s.chomp! | |
headers = {} | |
s.split("\t").each_with_index do |header, i| | |
headers[header] = i | |
end | |
with_podium = {} | |
all = {} | |
while s = gets | |
s.chomp! | |
row = s.split("\t") | |
# must be Spanish | |
next unless row[headers["personCountryId"]] == "Spain" | |
all[row[headers["personId"]]] = true | |
# the round must be a final or combined final (see RoundTypes.tsv) | |
next unless %w[c f].include?(row[headers["roundTypeId"]]) | |
# result must be in top 3 positions | |
next unless row[headers["pos"]].to_i <= 3 | |
# best must not be DNF / DNS | |
next unless row[headers["best"]].to_i > 0 | |
with_podium[row[headers["personId"]]] = true | |
end | |
puts with_podium.length | |
puts all.length | |
puts with_podium.length.fdiv(all.length) * 100.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment