KMCounter
KMCounter copied to clipboard
能不能弄个柱状图 横向对比每天的按键数
这样比较直观显示每天的摸鱼情况hh
我也有相同的需求,或者能导出csv文件自己做表也是极好的,希望开发者还能维护
我自己做了一个 https://github.com/pattazl/showKeyBoard 柱状图,历史数据曲线,数据导出等功能都有
写了一个Python脚本,简单做一下数据分析,有需要的可以使用。
# Import required libraries
import re
from collections import defaultdict
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use("TkAgg")
import pandas as pd
# Read the file with UTF-16 encoding
with open('D:\GreenSoft\KMCounter.ini', 'r', encoding='utf-16') as file:
file_content = file.readlines()
# Initialize a dictionary to store the data
data_dict = defaultdict(lambda: {'lbcount': 0, 'rbcount': 0, 'wheel': 0, 'move': 0, 'keystrokes': 0})
# Regular expression pattern to extract date in the format YYYYMMDD and the relevant data
pattern = re.compile(r'\[(\d{8})\]')
key_patterns = ['lbcount', 'rbcount', 'wheel', 'move', 'keystrokes']
# Extract data
current_date = None
for line in file_content:
# if ==[total]==, then skip
if line.strip() == '[total]':
current_date = None
continue
date_match = pattern.match(line.strip())
if date_match:
current_date = date_match.group(1)
current_date = f"{current_date[:4]}-{current_date[4:6]}-{current_date[6:]}"
continue
if current_date:
for key in key_patterns:
if line.startswith(key):
value = float(line.split('=')[1].strip())
data_dict[current_date][key] = value
# Convert the defaultdict to a normal dict
data_dict = dict(data_dict)
# Convert the data dictionary to a DataFrame
df = pd.DataFrame.from_dict(data_dict, orient='index')
df.index = pd.to_datetime(df.index)
# Filter out rows with 'total' in the index
df_filtered = df[~df.index.astype(str).str.contains('total', case=False)]
# Normalize the data for plotting
df_filtered_normalized = (df_filtered - df_filtered.min()) / (df_filtered.max() - df_filtered.min())
# Plotting
fig, ax = plt.subplots(figsize=(15, 10))
for column in df_filtered_normalized.columns:
df_filtered_normalized[column].plot(ax=ax, marker='o', label=column)
ax.set_xlabel('Date')
ax.set_ylabel('Normalized Value')
ax.set_title('Comparison of lbcount, rbcount, wheel, move, and keystrokes Over Time')
ax.legend()
plt.tight_layout()
plt.show()
现在可以叫chatgpt画了
我也有相同的需求,或者能导出csv文件自己做表也是极好的,希望开发者还能维护
目录下的ini文件里就是数据,自己解析呗。