-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseDataIntoFiles.py
More file actions
40 lines (34 loc) · 1.02 KB
/
parseDataIntoFiles.py
File metadata and controls
40 lines (34 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
import sys
import os
import pdb
def main():
# Opens the file that contains all info
with open("commentCrawler.output", "r") as fullFile:
femaleCounter = 0
maleCounter = 0
for line in fullFile.readlines():
line = line.strip()
# Checks the gender of the professor to name the file
if "Teacher gender:" in line:
gender = line[16:]
print gender
print "here too"
if gender == "male":
print "Camer"
fileName = "allData/" + "male" + str(maleCounter) + ".txt"
newReview = open(fileName, "w+")
maleCounter += 1
if gender == "female":
print "here too"
fileName = "allData/" + "female" + str(femaleCounter) + ".txt"
newReview = open(fileName, "w+")
femaleCounter += 1
# Collects each review and writes it to the appropriate file
if "Teacher name: " not in line:
if "School name: " not in line:
if "Teacher gender: " not in line:
if "Teacher comments:" not in line:
print line
newReview.write(line + '\n')
if __name__ == "__main__":
main()