-
Notifications
You must be signed in to change notification settings - Fork 1
/
makeDatasets.py
48 lines (41 loc) · 1.43 KB
/
makeDatasets.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
47
48
import os
import re
class MakeDataSets:
def __init__(self):
self.files = os.listdir("./datasets/")
self.changes = self.isDataSetsAdded()
self.left_csv = './left.csv'
self.right_csv = './right.csv'
def makeDataSet(self):
left = []
right = []
for file_ in self.files:
if re.search('.*_left\.csv$', file_):
print(file_)
left.append(file_)
if re.search('.*_right\.csv$', file_):
print(file_)
right.append(file_)
if os.path.exists(self.left_csv):
os.remove(self.left_csv)
for file_ in left:
with open(self.left_csv, 'a+') as f:
f_ = open('./datasets/' + file_, 'r')
f.write(f_.read())
if os.path.exists(self.right_csv):
os.remove(self.right_csv)
for file_ in right:
with open(self.right_csv, 'a+') as f:
f_ = open('./datasets/' + file_, 'r')
f.write(f_.read())
file_d = open('changes_file', 'w+')
file_d.write(str(len(self.files)))
file_d.close()
def isDataSetsAdded(self):
file_ = open('changes_file', 'r')
if int(file_.read()) == len(self.files):
return False
else:
return True
if __name__ == "__main__":
MakeDataSets().makeDataSet()