-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsvReadOut.py
More file actions
50 lines (35 loc) · 1.02 KB
/
csvReadOut.py
File metadata and controls
50 lines (35 loc) · 1.02 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
import csv
def readMyFile(filename):
d={}
header = []
values = []
time = []
emotion = []
with open(filename) as csvDataFile:
csvReader = csv.DictReader(csvDataFile)
for row in csvReader:
for column, value in row.iteritems():
d.setdefault(column, []).append(value)
header = d.keys()
values = d.values()
time = values[1]
emotion = values[0]
print(time)
print(len(time))
print(emotion)
print(len(emotion))
print("This is the end of the file")
return time, emotion
time,emotion = readMyFile('dataAudio.csv')
time2,emotion2 = readMyFile('dataVisual.csv')
writeArr = []
for i in range(0,len(time)):
emoM = (float(emotion[i])+float(emotion2[i]))/2
tempArr = [time[i],emoM]
writeArr.append(tempArr)
myFile = open('dataset.csv', 'w')
print(writeArr)
with myFile:
writer = csv.writer(myFile,lineterminator='\n')
writer.writerow(["time","emotion"])
writer.writerows(writeArr)