Skip to content

Instantly share code, notes, and snippets.

@prydt
Created May 19, 2020 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prydt/445ab6983493c85d9a074782d25b5e73 to your computer and use it in GitHub Desktop.
Save prydt/445ab6983493c85d9a074782d25b5e73 to your computer and use it in GitHub Desktop.
#
# a script to return averages of hoplite output layers in CSVs -- Pranoy
#
import csv
import glob
import numpy as np
averages_list = []
layer_names = []
for file_name in glob.glob("*.csv"):
current_list = []
with open(file_name) as csvf:
reader = csv.reader(csvf, delimiter=",")
for row in reader:
if row[0] == "layer=" and row[1] not in layer_names:
layer_names.append(row[1])
if row[0] == "average=":
current_list.append(float(row[1]))
averages_list.append(current_list)
avg = np.mean(np.array(averages_list), axis=0)
for i, aver in enumerate(avg):
print("{}: {}".format(layer_names[i], aver))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment