-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate_star_file.py
More file actions
42 lines (38 loc) · 1.01 KB
/
Copy pathgenerate_star_file.py
File metadata and controls
42 lines (38 loc) · 1.01 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
import csv
import os
import codecs
def readCSV(fileName):
data = []
with open(fileName, 'rt') as csvfile:
rows = csv.reader(csvfile, delimiter=',', quotechar='|')
for row in rows:
data.append(row)
csvfile.close()
data = data[1:]
return data
def createCorpus():
fileWrite = open("concat.txt", "w", encoding = "utf-8")
string = ""
rows = readCSV("metadata.csv")
for row in rows:
string += "**** "
i = 0
for col in row:
i+=1
if i<=21:
if i <= 9:
string += "*var0" + str(i) + "_" + col+" "
else:
string += "*var" + str(i) + "_" + col+" "
file = open("corpus2/"+row[0]+".txt", "r", encoding = "utf-8")
string += "\n\n"+file.read()+ "\n\n"
file.close()
fileWrite.write(string)
fileWrite.close()
if __name__ == '__main__':
# data = readCSV("/home/mudit/Desktop/Internship 2018/MMS CSVs/outputMMS3.csv") + readCSV("/home/mudit/Desktop/Internship 2018/MODI CSVs/output4.csv")
# createCSV("completeCSV.csv", data)
# createCorpus()
# changeEncoding()
createCorpus()
# replace()