Created
March 25, 2020 12:46
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import nltk | |
from tqdm import tnrange | |
import re | |
import gdelt | |
# Version 2 queries | |
gd2 = gdelt.gdelt(version=2) | |
# days | |
lengths = [31, 29, 20] #days in Jan, feb, Mar | |
lengths = [x + 1 for x in lengths] | |
# Getting data from gdelt | |
for i in range(1, len(lengths)+1): | |
month_str = str(i).zfill(2) | |
for j in range(1, lengths[i - 1]): | |
day_str = str(j).zfill(2) | |
results = gd2.Search(['2020 {} {}'.format(month_str, day_str)], table='events',coverage=True, output='pandas dataframe')#, translation=True) | |
df_path = "2020{}{}.csv".format(month_str, day_str) | |
results.to_csv("/Volumes/My Passport/Melbourne/Omdena/corona_virus/data/scrapped_articles_en_v2/" + df_path, index = None, header=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment