-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhashtagzeit.py
44 lines (33 loc) · 1.3 KB
/
hashtagzeit.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
import csv
from random import randint
import numpy as np
import matplotlib.pyplot as plt
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
import datetime
in_file = open("C:/Users/acedon/Desktop/hashtagnew1.csv","r");
reader = csv.reader(in_file,delimiter=";"); #csv datei wird eingelesen und im platzhalter reader getan
x = input("Geben sie den Namen des Hashtags ein, dessen Vorkommen sie zeitlich visualisieren möchten:")
timestamps = []; #initialisiere leere liste fuer alle zeitstempel des bestimmten hashtags
for row in reader:
if (x == row[1]):
timestamps.append(row[2]); #fülle liste mit zeitstempel
counter = {}; #initialisiere dictionary mit zeitstempel als schlüssel und zähler als wert
for i in timestamps:
if i not in counter:
counter[i] = 0;
for j in timestamps:
if (i == j):
counter[i] += 1; #counter eindeutig gefüllt
date = [];
counters = [];
for i in counter: #übertrage zeitstempel von counter in liste
date.append(i);
for j in counter: #übertrage die zähler in eigene liste
counters.append(counter[j]);
data2 = [go.Bar( #plotte die beiden listen als y und x achse
x=date,
y=counters
)]
py.iplot(data2, filename='basic-bar2')