<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vishnu Ks on Medium]]></title>
        <description><![CDATA[Stories by Vishnu Ks on Medium]]></description>
        <link>https://medium.com/@hackerkid?source=rss-6f57bec9dae5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Z4I5GLBAEweCWKPuSE9rew.jpeg</url>
            <title>Stories by Vishnu Ks on Medium</title>
            <link>https://medium.com/@hackerkid?source=rss-6f57bec9dae5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 03:46:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hackerkid/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building A Covid-19 Tracker using Google Sheets in Less than 15 mins]]></title>
            <link>https://medium.com/@hackerkid/building-a-covid-19-tracker-using-google-sheets-in-less-than-15-mins-8220f3b3f753?source=rss-6f57bec9dae5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8220f3b3f753</guid>
            <category><![CDATA[google-data-studio]]></category>
            <category><![CDATA[google-sheets]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Vishnu Ks]]></dc:creator>
            <pubDate>Wed, 01 Apr 2020 15:57:00 GMT</pubDate>
            <atom:updated>2020-04-04T11:24:21.162Z</atom:updated>
            <content:encoded><![CDATA[<p>I was not a big fan of Google Sheets till a few days back. I mean how excelited can you get about a spreadsheet software? Then I found out that Google Sheets can run JavaScript and do cron jobs. Yeah. You didn’t misread that. If you are surprised like I was, continue reading. I will show how to write and execute Javascript and run Cron jobs in Google Sheets by building a Covid-19 tracker in less than 15 mins. The idea behind the blog post is to demonstrate how powerful Google Sheet Ecosystem is and how you can build some of your side projects on top of it without writing a ton of code.</p><p>I will show how to write and execute Javascript and run Cron jobs in Google Sheets by building a Covid-19 tracker. The idea behind the blog post is to demonstrate how powerful Google Sheet Ecosystem is and how you can build some of your side projects on top of it without writing a ton of code.</p><p>For simplicity, we will build a tracker that tracks the total number of cases globally. We need 3 components for building this.</p><ol><li>A Google Sheet to store the date and cases reported.</li><li>Keeping Google sheets in sync with realm time data</li><li>Displaying data from Google Sheets as an Interactive Graph.</li></ol><h3>1. A Google Sheet to store the date and number of cases</h3><p>The first thing we need to create is a Google sheet to store the data. You can create a new sheet by going to <a href="https://sheet.new/">https://sheet.new</a>.</p><p>Use column A of the sheet storing the date and column B for storing the total number of cases reported so far. Now go ahead and name the column A as date and column B as cases</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/0*Wqjd6XRf-P1bEStW.png" /></figure><p>Next, we need to populate the sheet with the historical data of Covid-19 cases. For that, we can use the following API.</p><p><a href="https://corona.lmao.ninja/v2/historical/all">https://corona.lmao.ninja/v2/historical/all</a></p><p>This API returns the global historical data of Covid-19. You can click on the link to see how the response would look like.</p><p>But how do you fetch the data from the API and insert it into Google Sheets?</p><p>For that, we can make use of Google AppsScript.</p><blockquote><em>Google AppsScript is a rapid application development platform that makes it fast and easy to create business applications that integrate with G Suite.</em></blockquote><p>If that doesn’t make much sense, you can think of AppsScript as a code editor in which you can run and execute Javascript. It comes with preinstalled libraries that you can use for reading and editing data in GSuite products.</p><p>You can access the AppsScript code editor by opening the Tools menu and clicking on Code Editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/0*rYxVDV84vpThHUEh.png" /></figure><p>Now copy-paste the following code to the editor.</p><pre>function getHistoricalData() {<br>  const url = &quot;https://corona.lmao.ninja/v2/historical/all&quot;;<br>  var response = UrlFetchApp.fetch(url);<br>  return JSON.parse(response)[&quot;cases&quot;];<br>}</pre><pre>function populateHistoricalData() {<br>  const sheet = SpreadsheetApp.getActive().getSheetByName(&#39;Sheet1&#39;);<br>  const historicalData = getHistoricalData();</pre><pre>  for (const date in historicalData) {<br>    const cases = historicalData[date];<br>    sheet.appendRow([date, cases]);<br>  }<br>}</pre><p>The code will make a request to <a href="https://corona.lmao.ninja/v2/historical/all">https://corona.lmao.ninja/v2/historical/all</a>, fetch the result, parse and store it in your Google Sheet.</p><p>Save the code by pressing the Save option in File menu. After that choose populateHistoricalData as the default function to execute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/0*bU9cK-W4071RYb0x.png" /></figure><p>Now click on the run ▶️ button. This will run populateHistoricalData function. The function would populate the Google sheet with the historical data from the API. If everything works fine your sheet would look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/0*04pF1BOUrpBCy2Pf.png" /></figure><h3>2. Keeping Google sheets in sync with realm time data</h3><p>The data we have inserted in the Google Sheets is historical and doesn’t include the cases of the current day. So we need to figure out a way to keep the sheet updated.</p><p>We can do this is by making requests every few minutes to an API that returns the latest data.</p><p><a href="https://corona.lmao.ninja/all">https://corona.lmao.ninja<strong>/all</strong></a> is such an API.</p><p>The following code makes requests to https://corona.lmao.ninja<strong>/all</strong> and update today&#39;s count.</p><pre>function getTotalCasesSoFar() {<br>  const url = &quot;https://corona.lmao.ninja/all&quot;;<br>  var response = UrlFetchApp.fetch(url);<br>  var jsonResponse = JSON.parse(response);<br>  const casesSoFar = jsonResponse[&quot;cases&quot;];<br>  return casesSoFar;<br>}</pre><pre>function updateTotalCasesToday() {<br>  const sheet = SpreadsheetApp.getActive().getSheetByName(&#39;Sheet1&#39;);<br>  const todayDate = new Date();<br>  todayDate.setHours(0, 0, 0, 0);<br>  const lastRowId = sheet.getLastRow();<br>  const lastDate = sheet.getRange(&quot;A&quot; + lastRowId).getValue();<br>  <br>  const casesSoFar = getTotalCasesSoFar();<br>  if (lastDate.getTime() === todayDate.getTime()) {<br>    const oldCountCell = sheet.getRange(&quot;B&quot; + lastRowId);<br>    oldCountCell.setValue(casesSoFar);<br>  } else {<br>    sheet.appendRow([todayDate, casesSoFar])<br>  }<br>}</pre><p>Copy and paste the code below our existing code in the script editor. Now choose updateData as the default function and click run. If all goes well, you can see a new row getting inserted which contains today&#39;s date and cases so far. If you run the code again it will try to update cases by making another request to the API. An update occurs if there is a change in number.</p><p>Now that we have the code ready for keeping the data in sync, we need to figure out a way to run this code automatically. It’s not ideal for us to click on the Run ▶️ button every few minutes. What we need is a cron job that runs this script every few minutes. For that, we can make use of Triggers.</p><p>Open edit menu and click on Current project&#39;s triggers. This will open a dashboard that looks like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4ta8km7v5fPzN3s8.png" /></figure><p>You can create a new trigger by clicking one create a new trigger. This will open a form. Set the function as updateTotalCasesToday and event source as Time-driven . You can set the minute interval as you like. In my case, I have set it to every 10 minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/0*jQK5GBc-uw3CJkTP.png" /></figure><p>Click Save to create the Trigger.</p><p>Voila! Google Apps Script will invoke the function every few minutes.</p><p>Now that our sheet is in sync with the latest data, let’s proceed to the final step.</p><h3>3. Displaying data from Google Sheet as an Interactive Graph</h3><p>For that, we can make use of Google Data Studio. Google Data Studio is a product used for making interactive reports and dashboards. We can use it for creating a time series graph from our Google Sheet.</p><p>Go to <a href="https://datastudio.google.com/">https://datastudio.google.com/</a> and create a new report.</p><p>Now choose Google Sheets as your data source and choose the Sheet that you created in the previous step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p0S9xzf57TpWo8Uf.png" /></figure><p>Now click on Insert menu and select Time series. This will insert a graph to your report.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/0*BkA35iiNHWxATzxO.png" /></figure><p>Now in the right side bar set the value of Date Range Dimension to Date and Dimension to Date column. Set the value of Metric to Cases and choose the Max aggregator. Max aggregator uses the maximum of cases values, if there are more than one rows with the same date.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/0*Q60VRY3gLXUxMrT_.png" /></figure><p>The report should now contain a time-series graph.</p><p>You can also insert a Date range that allows users to change the date range. For that click on insert and then choose Date range. The final result would look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7zCkbLCmB_3JyjCE.png" /></figure><p>You can share the report with anyone by clicking on Share. See the link below to see how will the report looks like when shared with someone.</p><p><a href="https://datastudio.google.com/open/14nOy1s9OWDxNRsGjPHFD1FqyO5MQqT-y">https://datastudio.google.com/open/14nOy1s9OWDxNRsGjPHFD1FqyO5MQqT-y</a></p><p>You can also embed the report in any website by clicking on the File menu and choosing Embed report. You can see the report embedded below for an example.</p><p>Great. We have now built a Covid-19 tracker. To recap</p><ul><li>We learned how to manipulate Google Sheets using JavaScript.</li><li>How to run cron jobs using Triggers.</li><li>How to create interactive graphs using Google Data Studio.</li></ul><p>The tutorial is only for demonstration purposes. I would not use the code, data, etc in production without doing due diligence. Hope this blog post was helpful :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8220f3b3f753" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>