You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.0 KiB

import pandas as pd
import datetime
import csv
import math
import os
import matplotlib.pyplot as plt
from shutil import copyfile
with open("/home/trackingv2/trackingv2.csv", "r") as f:
reader = csv.reader(f)
next(reader)
with open("/home/trackingv2/trackingv2.frac.csv", "w", newline='') as write:
writer = csv.writer(write)
writer.writerow(["fraction_nonv2", "datetime"])
for row in reader:
per = 0
if row[1] != "0" and row[2] != "0":
per = int(row[1]) / int(row[2])
per = round(per, 4)
writer.writerow([per, row[3]])
x_axis='datetime'
y_axis='fraction_nonv2'
df = pd.read_csv("/home/trackingv2/trackingv2.frac.csv")
title = "Fraction of HSDirs that are non-v2"
df.plot(kind="line", x=x_axis, y=y_axis, ylim=([0,1]), title=title, grid=True, rot=20, figsize=(6,5))
plt.savefig("/var/www/data/fraction_plot.png")
copyfile("/home/trackingv2/trackingv2.frac.csv", "/var/www/data/fraction_v2.csv")
print("plotted "+title)