-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotter.py
54 lines (33 loc) · 1.16 KB
/
plotter.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
import numpy as np
np.random.seed(9615)
import csv
#topics=[0,1,2,3,4]
files = ['OutputDTM0.csv', 'OutputDTM1.csv', 'OutputDTM2.csv', 'OutputDTM3.csv', 'OutputDTM4.csv']
mydict={}
xdates=[]
def getPlot():
datalist = []
for number in range(5):
with open(files[number], 'r') as csvfile:
dates = []
datadict = {}
reader = csv.reader(csvfile, delimiter='\n')
next(reader)# skip 'TopicID,Word,Year,Probability' -first row/heading
datadict["name"] = "topic" + str(number+1)
dicty=[]
dictannotes=[]
for line in reader:
if len(line)!=0:
res=[word for word in line[0].split(',')]
dicty.append(float('%.16f'%(float(res[3]))))
#dates.append(int(res[2]))
dates.append(res[2])
dictannotes.append(res[1])
xdates=dates
datadict["data"]=dicty
datadict["annotes"]=dictannotes
datalist.append(datadict)
returndict={}
returndict["datalist"]=datalist
returndict["xdates"]=xdates
return returndict