This script takes a CSV file containing new call records and cleans, validates, and processes it; appends it to the existing data; and updates the ArcGIS Online feature service.
- Introductory settings (setting variables, importing libraries)
- Import new data table into the geodatabase
- Import table
- Make sure date field isn't null and try again if so
- Make sure date field is in date format
- Only keep today's records
- Clean data
- Change county names to title case
- Remove non-Washington calls and those from unknown counties
- Add spaces to the substance category field for better display
- Make sure number fields are the correct field type
- Geocode the clean data
- Geocode with a county-based address locator
- Stop and complain if there are unmatched records
- Add new data to this month's table
- Delete tables from previous month(s)
- Create separate feature classes for today's cases and this hour's cases
- Create feature class for today's choropleth map
- Calculate number of cases per county for today
- Join today's county totals to the county polygons
- Delete intermediate tables and feature classes
- Update the ArcGIS Online feature service (this part taken from [https://github.com/arcpy/update-hosted-feature-service])