forked from htil/JITAI-HCI-Data-Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_csv.py
More file actions
114 lines (89 loc) · 4.45 KB
/
Copy pathtest_csv.py
File metadata and controls
114 lines (89 loc) · 4.45 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import csv
def getComprehensionData(location):
with open(location, 'r') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
for index, col in enumerate(csv_reader):
responses = []
questionID = []
# comprehension = {}
questionNum = 0
answerNum = 0
if (index == 0):
questionID = col
if (index > 0):
responses = col
for id in range(len(questionID)):
for response in range(len(responses)):
questionNum = questionNum + 1
print(
f'Question ID is: {questionID[id]}, and Question number is {questionNum}')
print(f'Response is: {responses[response]} \n')
# for response in range(len(responses)):
if "Eat less" in responses[response]:
eat_less = responses.count('Eat less')
elif "Eat more" in responses[response]:
eat_more = responses.count('Eat more')
elif "Eat slower" in responses[response]:
eat_slower = responses.count('Eat slower')
elif "Eat faster" in responses[response]:
eat_faster = responses.count('Eat faster')
print(f'Eat_Less is {eat_less} ')
print(f'Eat_More is {eat_more} ')
print(f'Eat_Slower is {eat_slower} ')
print(f'Eat_Faster is {eat_faster} \n')
# for response in range(len(responses)):
# # answerNum = answerNum + 1
# eat_less = responses[response].count('Eat less')
# eat_more = responses[response].count('Eat more')
# eat_slower = responses[response].count('Eat slower')
# eat_faster = responses[response].count('Eat faster')
# # print(f'Question ID is: {questionID[id]}, and Question number is {questionNum} \n')
# print(f'The number of Eat Less is: {eat_less} \n')
# print(f'The number of Eat More is: {eat_more} \n')
# print(f'The number of Eat Slower is: {eat_slower} \n')
# print(f'The number of Eat Faster is: {eat_faster} \n\n')
# elif (index > 0):
# responses = col
# print(responses, '\n')
# for x, row in enumerate(col):
# if(x < len(col)):
# questionNum = questionNum + 1
# if (row != ' '): # skip if empty
# response = responses[x]
# answerNum = answerNum + 1
# eat_less = response.count('Eat less')
# eat_more = response.count('Eat more')
# eat_slower = response.count('Eat slower')
# eat_faster = response.count('Eat faster')
# print(f'The number of Eat Less is: {eat_less} \n')
# print(f'The number of Eat More is: {eat_more} \n')
# print(f'The number of Eat Slower is: {eat_slower} \n')
# print(f'The number of Eat Faster is: {eat_faster} \n\n')
# print(f'Total number of question IDs: {questionNum} \n')
# print(f'Total number of responses: {answerNum} \n')
csv_file.close()
return questionID, responses
# def getComprehensionAnswerType(questionID, responses):
# if "Eat slower" in responses[questionID]:
# return "EAT_SLOWER"
# elif "Eat faster" in responses[questionID]:
# return "EAT_FASTER"
# elif "Eat less" in responses[questionID]:
# return "EAT_LESS"
# elif "Eat more" in responses[questionID]:
# return "EAT_MORE"
# elif "None of the above" in responses[questionID]:
# return "NONE"
def writeComprehensionData(comprehension):
print("Total responses: ", len(comprehension))
fieldNames = ["ID", "EAT_LESS", "EAT_MORE",
"EAT_SLOWER", "EAT_FASTER", "NONE"]
with open('comprehension_formatted.csv', 'w') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=fieldNames)
writer.writeheader()
for comp in comprehension:
writer.writerow(comp)
csvfile.close()
responses = getComprehensionData('/Users/ecm/Desktop/Comprehension_copy.csv')
# comprehension = getComprehensionAnswerType(questionID, responses)
# writeComprehensionData(comprehension)