prlitics / vrrr

0 stars 0 forks source link

load_state() function #2

Open prlitics opened 4 years ago

prlitics commented 4 years ago

Next up on the chopping block once we finish check_yaml is something that parses the yaml and loads in the voter file data based on the parameters in the file. I'm thinking we start with "easy" states (those that don't have to be built-up from several counties) next week. We'll complicate it with aggregated states afterwards. I have some pseudocode sketched out for this in my notebook, so I'll take point on that next week. Since you're so familiar with the file formats (for better or worse lol), could you shoot me a couple examples of states that use different delimiters (tab, csv, pipe, etc.) before our meeting next Wednesday?

prlitics commented 4 years ago

Two updates to load_state()

  1. Updated load_state() so that it accommodates dates. Required an assignment at the beginning (`date_format<-yaml[["date_format"]]) and an if condition in the loop to apply it. Managed to make it work for AK and WV (although I had to edit the WV YAML a little because of the time formatting---but not a big deal). But it seems like the simple version of load_state() is proving to be pretty robust!

  2. Got it prepped to build up a county aggregator. I've repackaged most of the current work for load_state() into a function called simple_case() (which I'll probably rename to something more descriptive later) and have it set to run if the YAML file says that it's not aggregated by county. My thought is if it is aggregated by county, we'll have it interact with the user in the console to get the OK and then just loop through simple_case() based off the number of counties in the state.

I'm gonna try and work on that functionality before our next meeting on Wednesday.