Skip to content

Instantly share code, notes, and snippets.

@cdmh
Created August 11, 2017 20:25
Show Gist options
  • Save cdmh/4906f4144858a45907116b49d92c172b to your computer and use it in GitHub Desktop.
Save cdmh/4906f4144858a45907116b49d92c172b to your computer and use it in GitHub Desktop.
convert parkrun results web page to CSV
library(tidyverse)
library(htmltab)
# right-click and save HTML
# this is the results page, e.g. http://www.parkrun.org.uk/henleyonthames/results/weeklyresults/?runSeqNumber=2
doc <- read_file("results _ henleyonthames parkrun_2.html")
df <- as_tibble(htmltab(doc=doc, which="//table[@id='results']"))
colnames(df) <- c("pos", "name", "time", "age_cat", "age_grade", "gender", "gender_pos", "note", "total_runs")
df$pos <- as.numeric(df$pos)
df$total_runs <- as.numeric(df$total_runs)
df$gender_pos <- as.numeric(df$gender_pos)
d1 <- as_tibble(df)
write.csv(d1, file = "results _ henleyonthames parkrun_2.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment