def momo(): """Fix the standard sharelock file and create the momo.csv in the standard location """ global STATS_FILE fixfile() d = csvmc.read_dict(STATS_FILE) def f(row): epic = row['epic'] rs6mb = float(row['rs6mb']) rs1y = float(row['rs1y']) rs6ma = (rs1y/100.0 + 1.0)/(rs6mb/100.0 + 1.0)*100.0 - 100.0 rs6ma = "{:.2f}".format(rs6ma) res = { 'epic' : epic, 'rs6ma' : rs6ma, 'rs6mb' : row['rs6mb'], 'rs1y': row['rs1y']} return res d1 = [] for r in d: try: rnew = f(r) d1.append(rnew) except ValueError: #print("Skipping:", rnew.epic) pass #csvmc.write_dict(d1, ROOT + '/momo.csv') with open(ROOT + '/momo.csv', "w") as f: w = csv.DictWriter(f, ["epic", "rs6ma", "rs6mb", "rs1y"]) w.writeheader() for r in d1: w.writerow(r)
def read_csv(): return csvmc.read_dict(ROOT + "/int/misc/calcs.csv")