Can Twitter Help Fight COVID-19?

Utkarsh Shahdeo
2 min readApr 26, 2021

--

It won’t be an exaggeration to say that the second wave of COVID-19 has wreaked havoc in India, arguably like never before. As I write this, there are millions of people battling for their lives with limited resources to serve them. WhatsApp groups and statuses are flooded with messages seeking any leads for oxygen cylinders, concentrators, beds, ICUs, and plasma donors. To a large extent, we Indians are collectively responsible for the situation we have got ourselves into. COVID-19 was far from over when we became way too complacent with our approach and comfortably ignored all precautions. Lo and behold, the second wave struck!

This blog ain’t about what went wrong and what could have been done better. Rather, I want to discuss how using Twitter and a developer account, we can help amplify important information to fight this horrendous situation. People are using Twitter as a channel to continuously broadcast updates on the availability of beds, oxygen, plasma donors, etc. A Twitter developer account and a short Python snippet can act as a medium for the flow of this information to relevant people.

The below block shows the complete code (with credentials masked) on how to implement this.

import tweepy
import csv
from textblob import TextBlob
consumer_key = "XXXX"
consumer_secret = "XXXX"
access_key = "XXXX"
access_secret = "XXXX"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth,wait_on_rate_limit=True)
csvFile = open('Delhi.txt', 'a',encoding='utf-8')csvWriter = csv.writer(csvFile)for tweet in tweepy.Cursor(api.search,q="#Delhi #Beds - filter:retweets",count=300,lang="en",
since="2021-04-24",until="2021-04-27").items():
clean = TextBlob(tweet.text)
csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')])

It uses three libraries — Tweepy, CSV, and TextBlob for extracting tweets with a given hashtag, cleaning it, and then writing the output on the TXT file. In the query (q), we can specify the city name and the type of requirement, for example, #Mumbai #Oxygen. We can specify the dates between which we want the tweets to be extracted. And finally, clean and write those extracted tweets into a TXT file. The output generated is shown in Figure 1.

Figure 1 — Output file of Tweets

We can perform a simple search (CTRL+F) on the output file for extracting the most relevant tweet. For instance, we can do a search for “Verified” and then manually visit those tweets to take a call on the authentic source. Once this script is up and running, the entire exercise takes hardly a few minutes to narrow down on a few authentic tweets and sources.

In case you have a Twitter developer account, please use this to help people in your circle. If you have basic coding skills, a new Twitter developer account takes around a couple of weeks to get activated. If neither, then spread information responsibly, verify the source, then put it on platforms such as Twitter at the earliest, and please stay at home as much as possible!

--

--

Utkarsh Shahdeo
Utkarsh Shahdeo

Written by Utkarsh Shahdeo

I write about technology concepts that I learn during the course of my work. Presently working as a Senior Consultant at Deloitte India.

No responses yet