-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakedata.py
35 lines (29 loc) · 1.26 KB
/
makedata.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
import os
# this allows me to create a data sheet that can easily be used in excel, or go
# straight to my favorite data analysis software, JASP
class DataSheet:
def __init__(self, col_names, participant, file_name):
self.col_names = col_names
self.file_name = "P" + str(file_name) + ".csv"
script_directory = os.path.dirname(os.path.abspath(__file__))
self.file_n = os.path.join(script_directory, "data", self.file_name)
with open(self.file_n, 'w') as data_sheet:
for col in col_names:
data_sheet.write(col + ',')
data_sheet.write("\n")
def writeSection(self, data_dict):
# From a dict passed by the user, this creates a list of the data, in order based on self.col_names, defined
# when the object is created
current_line = []
for col in self.col_names:
current_line.append(data_dict[col])
self.writeRow(current_line)
def writeRow(self, cols):
with open(self.file_n, 'a')as data_sheet:
for col in cols:
s = str(col)
data_sheet.write(s + ',')
data_sheet.write('\n')
def experimentSheet(self):
# This will copy all of the data into an experiment sheet.
pass