def getTweetDateStats(datesSet, countryInfo): tweetsAboutCountryBasePath = 'data/Tweets_About_Country/' tweetDateInfoDict = dict() for date in datesSet: tweetDateInfoDict[date] = dict() for country in countryInfo: completeCountryFilePath = tweetsAboutCountryBasePath + country["Name"] + '_tweets.csv' countryTweets = readCSVFile(completeCountryFilePath)
def getAllDates(countryInfo): tweetsAboutCountryBasePath = 'data/Tweets_About_Country/' dates = set() for country in countryInfo: completeCountryFilePath = tweetsAboutCountryBasePath + country["Name"] + '_tweets.csv' countryTweets = readCSVFile(completeCountryFilePath) for tweet in countryTweets: tweetDateTime = parse(tweet["created_at"]) tweetDate = tweetDateTime.date() dates.add(tweetDate) return sorted(list(dates))
def calculateSpheresOfInfluence(countryInfo, tweetsAboutCountryBasePath): spheresOfInfluence = [] for country in countryInfo: tweetsAboutCountryFilePath = tweetsAboutCountryBasePath + country["Name"] + '_tweets.csv' tweetsAboutCountry = readCSVFile(tweetsAboutCountryFilePath) countryInfluence = { 'name': country['Name'], 'coordinates': country['Coordinates'], 'code': country['Code'], 'color': country['Color'], '25%_distance': getSphereRadius(tweetsAboutCountry, 25), '50%_distance': getSphereRadius(tweetsAboutCountry, 50), '75%_distance': getSphereRadius(tweetsAboutCountry, 75) } spheresOfInfluence.append(countryInfluence) return spheresOfInfluence
def getCombinedTweets(): completeTweetsBasePath = 'data/Complete_Tweets/completeTweets' combinedCompleteTweets = [] fieldnames = ['id_str', 'created_at', 'coordinates', 'hashtags', 'text'] for i in xrange(1, 26): completeTweetsFilePath = completeTweetsBasePath + str(i) + '.csv' completeTweets = readCSVFile(completeTweetsFilePath) for tweet in completeTweets: tweetDict = { 'id_str': tweet['id_str'], 'created_at': tweet['created_at'], 'coordinates': tweet['coordinates'], 'hashtags': tweet['hashtags'], 'text': tweet['text'].lower() } combinedCompleteTweets.append(tweetDict) return combinedCompleteTweets