Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import plotly.graph_objects as go
- from collections import Counter
- from collections import OrderedDict
- def file_len(fname):
- with open(fname) as f:
- for i, l in enumerate(f):
- pass
- return i + 1
- def print_file(fname):
- file = open("logs/" + fname, 'r')
- line = file.readline()
- chat_count = []
- cnt = 1
- names = []
- while line:
- name = line.split()[3]
- name = name[:-1]
- line = file.readline()
- names += [name]
- cnt += 1
- name_list = dict(Counter(names))
- sort = OrderedDict(sorted(name_list.items(), key=lambda x: x[1]))
- keys, values = zip(*sort.items())
- fig = go.Figure(
- data = [go.Bar(y = values, x = keys)],
- layout_title_text = "Player Chat Count"
- )
- fig.show()
- def main():
- files = os.listdir("logs")
- len = []
- dates = []
- for string in files:
- date = string.split('-')[1]
- dates += [date]
- path = "logs/" + string
- flen = file_len(path)
- len += [flen];
- fig = go.Figure(
- data = [go.Scatter(y = len, x = dates)],
- layout_title_text = "OOC Chat Count"
- )
- fig.show()
- print_file("ooc_08-23-19.log")
- #main()
Advertisement
Add Comment
Please, Sign In to add comment