-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrganizeResults.py
executable file
·65 lines (50 loc) · 2 KB
/
OrganizeResults.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 30 10:42:38 2020
Load up all result files and organize them
Something like this will make it all a lot faster
with open("temp/merged_pure_python2.csv","wb") as fout:
# first file:
with open("temp/in/1.csv", "rb") as f:
fout.write(f.read())
# now the rest:
for num in range(2,101):
with open("temp/in/"+str(num)+".csv", "rb") as f:
next(f) # skip the header
fout.write(f.read())
@author: jasonsteffener
"""
import os
import csv
import pandas as pd
def main():
#DataFolder = "/Users/jasonsteffener/Documents/GitHub/ProcessModelsPython"
DataFolder = "/home/steffejr/Data"
cNames = ['NBoot', 'NSimMC', 'N', 'a', 'b', 'cP', 'typeA']
cNames.extend(['IEPercPow','TEPercPow', 'DEPercPow', 'aPercPow', 'bPercPow'])
cNames.extend(['IEBCPow','TEBCPow', 'DEBCPow', 'aBCPow', 'bBCPow'])
cNames.extend(['IEBCaPow','TEBCaPow', 'DEBCaPow', 'aBCaPow', 'bBCaPow'])
cNames.extend(['SaMean', 'SaStd', 'SbMean', 'SbStd', 'ScPMean', 'ScPStd', 'SIEMean', 'SIEStd'])
cNames.extend(['IEBiasMean', 'IEBiasStd', 'IEBSskewMean', 'IEBSskewStd', 'IEBSskewStatMean', 'IEBSskewStatStd'])
# How many result files are there?
df = pd.DataFrame(columns=cNames)
count = 0
# Read the data
count = 0
for filename in os.listdir(DataFolder):
# if filename.endswith(".csv"):
if filename.endswith(".csv") and filename.startswith('SimData'):
print(os.path.join(DataFolder, filename))
with open(os.path.join(DataFolder, filename), newline='') as f:
reader = csv.reader(f)
data = list(reader)
li = []
for i in data:
li.append(i[0])
row = pd.Series(li, index = cNames)
df = df.append(row, ignore_index = True)
count += 1
df.to_csv("SummaryDataFile.csv")
if __name__ == "__main__":
main()