Add columns and notes.

This commit is contained in:
mattbk 2024-04-07 10:17:22 -05:00
parent 3b9d756f6f
commit 08b1b3edc5

View File

@ -3,6 +3,9 @@ library(rvest)
library(dplyr) library(dplyr)
library(tidyr) library(tidyr)
# sudo crontab -e
# 5 9 * * * su matt -c "cd /home/matt/ham-radio-licenses/; Rscript /home/matt/ham-radio-licenses/scrape-arrl-fcc.R">/dev/null 2>&1
arrl_url <- "https://www.arrl.org/fcc-license-counts" arrl_url <- "https://www.arrl.org/fcc-license-counts"
# Read the page # Read the page
@ -25,12 +28,16 @@ tab <- d_raw %>%
bind_cols(Date = date_raw, .) %>% bind_cols(Date = date_raw, .) %>%
# Insert Tech Plus for compatibility # Insert Tech Plus for compatibility
mutate("Tech-Plus" = NA, mutate("Tech-Plus" = NA,
.before = General) .before = General) %>%
mutate(a=NA, b=NA, c=NA, d=NA, e=NA, f=NA, g=NA,
source_name = "ARRL FCC License Counts",
source_detail = "http://www.arrl.org/fcc-license-counts")
# Append table # Append table
write.table(tab, file = "out/arrl-fcc-licenses-scraped.csv", sep = ",", write.table(tab, file = "out/arrl-fcc-licenses-scraped.csv", sep = ",",
append = TRUE, quote = FALSE, append = TRUE, quote = FALSE,
col.names = TRUE, row.names = FALSE) col.names = TRUE, row.names = FALSE,
na = "")
# Clean up table to remove any duplicates (sometimes the page isn't updated regularly) # Clean up table to remove any duplicates (sometimes the page isn't updated regularly)
db <- read.csv("out/arrl-fcc-licenses-scraped.csv") db <- read.csv("out/arrl-fcc-licenses-scraped.csv")
@ -38,5 +45,6 @@ db2 <- db %>% distinct(.keep_all = TRUE) %>%
filter(Date != "Date") filter(Date != "Date")
write.csv(db2, "out/arrl-fcc-licenses-scraped.csv", write.csv(db2, "out/arrl-fcc-licenses-scraped.csv",
quote = F, quote = F,
row.names = F) row.names = F,
na = "")