-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
105 lines (76 loc) · 3.52 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
__author__ = 'luizcartolano'
from manageTweets import ManageTweets
from manageGoogle import ManageGoogle
import os
#----------------------------- MAIN -----------------------------
def workerTwitter(city, path_twitter, path_heatMapT):
# instance the managerTweets object
manager = ManageTweets()
# reading the json file and store in a dictionary
print("Reading json: ")
docs = manager.read(path_twitter,'tweets_campinas.json')
# deleting possible bots on the saved tweets
print("Deleting bots: ")
docs = manager.deleteBot(docs)
print("Slicing docs: ")
# slicing the tweets by hour
tweets_hour = manager.slicingDocsHour(docs)
# slicing the tweets by day
tweets_day = manager.slicingDocsDay(docs)
# slicing tweets by periods of a day (dawm, morning, afternoon, night)
tweets_range = manager.slicingDocsRange(docs)
# deleting the non-split list of tweets
del docs[:]
print("Plotting heat map: ")
# plotting the heatMaps for the list of tweets sliced by hours
manager.plotMap(path_heatMapT + "hours/", tweets_hour, city)
# plotting the heatMaps for the list of tweets sliced by days
manager.plotMap(path_heatMapT + "days/", tweets_day, city)
# plotting the heatMaps for the list of tweets sliced by ranges
manager.plotMap(path_heatMapT + "ranges/", tweets_range, city)
return
def workerGoogle(dates, path_google, path_googleD, path_googlePol):
# instance the managerTweets object
manager = ManageGoogle()
# reading the json file and store in a dictionary
print("Reading json: ")
docs = manager.read(path_google)
# print("Getting interest dates: ")
# routes = manager.slicingDocs(dates,docs)
# print("Printing routes datas on a specific file:")
# manager.printFileRoutes(routes,path_googleD)
# for key,value in routes.iteritems():
# lts = []
# lgs = []
# for data in value:
# points = manager.decode_polyline(data["polyline"])
# lt_p,lg_p = zip(*points)
# lts = tuple(lts) + lt_p
# lgs = tuple(lgs) + lg_p
# lat_points = list(lts)
# lgt_points = list(lgs)
# manager.plottingHeatmap(path_googlePol, key, lat_points, lgt_points, 'campinas')
# print(docs)
print("Making html pages:")
manager.makeHTML(docs)
def main():
# path to the google json file
path_google = '/Users/luizeduardocartolano/Dropbox/DUDU/Unicamp/Iniciacao_Cientifica/workspace/Dados/google/'
# path to the twitter json file
path_twitter = '/Users/luizeduardocartolano/Dropbox/DUDU/Unicamp/Iniciacao_Cientifica/workspace/Dados/'
# path to the heatMap directory
path_heatMapT = '/Users/luizeduardocartolano/Dropbox/DUDU/Unicamp/Iniciacao_Cientifica/workspace/Dados/heatMaps/'
# path to write datas from google
path_googleD = '/Users/luizeduardocartolano/Dropbox/DUDU/Unicamp/Iniciacao_Cientifica/workspace/Dados/routesTimes/'
path_googlePol = '/Users/luizeduardocartolano/Dropbox/DUDU/Unicamp/Iniciacao_Cientifica/workspace/Dados/polMaps/'
# list with cities where data was collected
cities = ['campinas']
dates = ['2018-02-12','2018-02-13','2018-02-14','2018-02-15']
workerGoogle(dates, path_google, path_googleD, path_googlePol)
# for going through the cities and carrying out the process for each one of them
# for city in cities:
# # function that takes care of the process for each city
# workerTwitter(city)
return
if __name__ == '__main__':
main()