-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocs.py
47 lines (42 loc) · 1.79 KB
/
docs.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
import csv
trueCounter = 1 #used to help label docs
misinformedCounter = 1 #used to help label docs
documentCounter = 1 #used to help label docs
#open Vaccine Dataset.csv to get text
with open('CSVFiles/Vaccine Dataset.csv', 'r') as csvfile:
reader = csv.reader(csvfile, dialect='excel')
for row in reader:
if(row[2] != 'Text'):
text = row[2] #text is in third cell of csv
if(row[3] == 'TRUE'):
#write text results to txt file
directory = 'Documents/ClassifiedDocuments/'
label = 'True' + str(trueCounter) + '.txt'
filename = directory + label
file = open(filename, "w")
file.write(text)
file.close()
trueCounter = trueCounter + 1
elif(row[3] == 'MISINFORMED'):
#write text results to txt file
directory = 'Documents/ClassifiedDocuments/'
label = 'Misinformed' + str(misinformedCounter) + '.txt'
filename = directory + label
file = open(filename, "w")
file.write(text)
file.close()
misinformedCounter = misinformedCounter + 1
#open Text.csv to get custom search text
with open('CSVFiles/Text.csv', 'r') as csvfile:
reader = csv.reader(csvfile, dialect='excel')
for row in reader:
if(row[2] != 'Text'):
text = row[2] #text is in third cell of csv
#write text results to txt file
directory = 'Documents/UnlabeledDocumenets/'
label = 'Unknown' + str(documentCounter) + '.txt'
filename = directory + label
file = open(filename, "w")
file.write(text)
file.close()
documentCounter = documentCounter + 1