inspired by amit agarwal's (@labnol) work on building a covid19 tracker in google sheets, i thought it might do some good if we could also get some visualization around it - while part of the data that's being gathered for this setup is built using google apps script, a good chunk of it is also contributed by the
=IMPORTHTML function that exists natively on sheets.
while working on apps script for a project at work, the task got me thinking that i've not been appreciating the formulas that already exist in spreadsheets for our benefit, enough. i suppose, while working towards building the data studio dashboard, this thought was very much in the fore front of my head.
lucky for us, the indian ministry of health (moh) is diligently updating information on their homepage where the data is being updated on a table created using html - lucky for us, google spreadsheets already provides us with a way to scrape information specifically from there html elements -
this is precisely what i ended up doing on my sheet, where the first tab consists of a mildly complex formula to handle a couple things, like -
#s from the data using
- convert numbers from string (text) to an actual number format using
- and finally, be able to handle all other erroneous exceptions using
this is what the formula looks like in its current state -
next was to write a simple apps script that took the data from the source sheet that we just configured using spreadsheet formulas and then log it chronologically on another tab.
note that what i do here is instead of logging every attempt, i delete the older data and then capture the new set of information; that way, i don't end up storing more rows that what i actually require.
in order to be able to create a really good-looking and obviously, an accurate geo-heat-map in google data studio, i also had to ensure that i had the perfect mapping of all the locations in it's various formats - this was updated manually on another sheet that I then got to use as blended data sets in data studio.
the final task was to simply connect the wrangled data to data studio using their sheets connector 😊