File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ hostname_dic = {}
2+ with open ("chrome_history.csv" , encoding = "utf-8" ) as csvfile :
3+ csv_reader = csv .reader (csvfile )
4+ birth_header = next (csv_reader )
5+ for row in csv_reader :
6+ hostname = parse .urlparse (row [0 ]).hostname
7+ hostname_dic [hostname ] = hostname_dic .get (hostname , 0 ) + 1
8+ sorted (hostname_dic .items (),key = lambda x :x [1 ],reverse = True )
9+
10+
11+ c = (
12+ Pie ()
13+ .add (
14+ "" ,
15+ [
16+ list (z )
17+ for z in zip (
18+ list (hostname_dic )[0 :10 ],
19+ list (hostname_dic .values ())[0 :10 ],
20+ )
21+ ],
22+ center = ["40%" , "50%" ],
23+ )
24+ .set_global_opts (
25+ title_opts = opts .TitleOpts (title = "历史记录" ),
26+ legend_opts = opts .LegendOpts (type_ = "scroll" , pos_left = "80%" , orient = "vertical" ),
27+ )
28+ .set_series_opts (label_opts = opts .LabelOpts (formatter = "{b}: {c}" ))
29+ .render ("pie_scroll_legend.html" )
30+ )
31+
32+ print (hostname_dic )
You can’t perform that action at this time.
0 commit comments