Skip to content

Instantly share code, notes, and snippets.

@Nikhel1
Created Mar 25, 2020
Embed
What would you like to do?
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