  @AshaRajagopal/

# Chp. 7 lab 1 ## Taking data from a CVS and importing it into python

Files
• main.py
• summary.txt
• tech.csv
main.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
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
```
```"""
Landon Goetz, Alex Itzenhuiser, Asha Rajagopal
5 march 2019
chapter 7 lab 1
Techonology survey lab
"""

def displaydata():
"""Displays the number of submissions"""
for i in final:
b = i.split(",")
final2.append(b)

count = 0
print(' {:^14} {:^14} {:^14} {:^14} \n'.format("Question 1:","Question 2:","Question 3:","Question 4:"))
for i in final2:# counts submissions
print(f'|{i:^14}|{i:^14}|{i:^14}|{i:^14}|')
time.sleep(0.05)
count += 1
print("\nThere are" , str(count) , "submissions")
def countdata(num):
"""counts the number of responses and the answers for each question"""
total = 0
sa = 0
a = 0
n = 0
d = 0
sd = 0
e = 0
for i in final2:
if i[num-1] == "Strongly Agree": # tallys up the number of each specific answer per question
sa += 1
elif i[num-1] == "Agree":
a += 1
elif i[num-1] == "Neutral":
n += 1
elif i[num-1] == "Disagree":
d += 1
elif i[num-1] == "Strongly Disagree":
sd += 1
else:
e +=1
print("For question {}:".format(num))# prints data collected
print("there are", str(sa),"Strongly Agree responses")
print("there are", str(a),"Agree responses")
print("there are", str(n),"Neutral responses")
print("there are", str(d),"Disagree responses")
print("there are", str(sd),"Strongly Disagree responses")
against = sa+a
fta = d+sd
if num == 1:
if against >= fta:
total -= 1
else:
total +=1
else:
if against >= fta:
total +=1
else:
total -= 1
def summary(total):
""" based on the data analyzed from countdata() and from displaydata(), we can come to a conclusion about our data using this function"""
if total > 0:
summary = open("summary.txt","w")
summary.write("People benefit from tech, based the responses from our questions.\n")
summary.write("The answers given from questions 2, 3, and 4 support the use of technology in human relations.\n")
summary.write("Overall, social media and other platforms strenghten human realtionships.")
summary.close()
elif total == 0:
summary = open("summary.txt","w")
summary.write("Based on our data, people do not benefit nor suffer from the interference of tech within human relationships.")
summary.close()
else:
summary = open("summary.txt","w")
summary.write("based on the data gathered from countdata() and displaydata(), technology is detrimential to human health.")

def main():
print("Welcome to the technology survey evaluation program!\n")
time.sleep(0.5)
print("The responses from our survey:")
responses = list(files)
for i in responses: # removing the \n that is generated from the csv file
if "\n" in i:
i = i[:-1]
final.append(i) # the append recreates the immutable list without the /n
else:
final.append(i)
print("\n")

displaydata() # displays total number of submissions
print("\n\n")
files.seek(0)
for i in range(1,5):
total = countdata(i)
time.sleep(0.5) # call function to give question by question breakdown
print("\n")
summary(total)
input("\nPress enter to exit")
import csv
import time
files = open("tech.csv")
final = []
final2 = []
main()```
Fetching token