-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·37 lines (23 loc) · 947 Bytes
/
test.py
File metadata and controls
executable file
·37 lines (23 loc) · 947 Bytes
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
lines = open("StatsForQuestionsWithCodedCommentsGender.csv").readlines()
f = open("StatsForQuestionsWithCodedCommentsGenderRatio.csv","w")
line = lines[0].replace("\n","")+"|maleViableRatio|femaleViableRatio|maleMeanRatio|femaleMeanRatio\n"
f.write(line)
for line in lines[1:]:
col = line.split("|")
viableMale, viableFemale = int(col[-4]),int(col[-3])
meanMale, meanFemale = int(col[-2]),int(col[-1])
totalMale, totalFemale = int(col[-6]),int(col[-5])
if totalMale == 0:
maleMeanRatio = "0"
maleViableRatio = "0"
else:
maleViableRatio = str(viableMale/totalMale)
maleMeanRatio = str(meanMale/totalMale)
if totalFemale == 0:
femaleMeanRatio = "0"
femaleViableRatio = "0"
else:
femaleViableRatio = str(viableFemale/totalFemale)
femaleMeanRatio = str(meanFemale/totalFemale)
newLine = line.replace("\n","")+"|"+maleViableRatio+"|"+femaleViableRatio+"|"+maleMeanRatio+"|"+femaleMeanRatio+"\n"
f.write(newLine)