forked from Tyler-Hecht/Coder-File-Reconciling
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecode_finder.py
More file actions
68 lines (60 loc) · 2.31 KB
/
recode_finder.py
File metadata and controls
68 lines (60 loc) · 2.31 KB
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
66
67
68
import os
import glob
from openpyxl import load_workbook
from pandas import *
from openpyxl.styles import Color, PatternFill, Font, Border
def main(output_file):
if os.name == "nt":
sep = "\\"
else:
sep = "/"
# gets the study information
with open('config.txt') as f:
lines = f.readlines()
try:
study = lines[1][:-1]
except:
print("No study given in config file. Make sure to put the study type on the second line")
exit(1)
if not study.strip().lower() in ["facetalk", "wls", "awl", "ewl"]:
print("Invalid study \"" + study + "\" in config file.")
exit(1)
else:
study = study.strip().lower()
try:
num_trials = int(lines[3].strip())
except:
print("No number of trials in config file. Make sure to put the number of trials on the fourth line")
exit(1)
if study in ["facetalk", "wls"]:
cols = 15
elif study in ["awl"]:
cols = 21
elif study in ["ewl"]:
cols = 23
path = os.getcwd()
input_path_1 = path + "/OUTPUT/"
input_path_2 = path + "/DatavyuToSupercoder/Output/"
trials_file = glob.glob(os.path.join(input_path_2, "*.xls"))[0].split(sep)[-1]
os.chdir(input_path_1)
output_wb = load_workbook(output_file)
output_sheet = list(list(output_wb)[2])
os.chdir(input_path_2)
trials_wb = read_excel(trials_file, skiprows=[0])
trial_times = trials_wb["Start Time (in elapsed time - Datavyu coding)"]
bad_trials = set()
redFill = PatternFill(start_color = 'FF0000', end_color = 'FF0000', fill_type = 'solid')
redFill2 = PatternFill(start_color = 'FFFF0000', end_color = 'FFFF0000', fill_type = 'solid')
# find the trials marked red
for i in range(1, num_trials+1):
row = output_sheet[i]
for j in range(0, cols):
cell = row[j]
if cell.fill == redFill or cell.fill == redFill2:
bad_trials.add(i)
if len(bad_trials) > 1:
print("\n" + str(len(bad_trials)) + " bad trials still found. Check averages across coders in OUTPUT folder.")
elif len(bad_trials) == 1:
print("1 bad trial still found. Check averages across coders in OUTPUT folder.")
else:
print("Complete: all trials fixed")