mattkerlogue / google-covid-mobility-scrape

Script for scraping Google's COVID19 Community Mobility Reports [ARCHIVED]
MIT License
33 stars 14 forks source link

Code duplication for PDF reading #6

Open matt-dray opened 4 years ago

matt-dray commented 4 years ago

Problem

Not much of a problem. Just some minor code duplication when reading a PDF.

Example

get_national_data() and get_subnational_data() both do this:

report_data <- pdftools::pdf_data(url)

Solution

Mild refactor to create a separate PDF-reading step that then feeds into e.g. get_national_data() and get_subnational_data().

Risk

Minimal. Some efficiency is gained from reading PDFs just once from a given URL.