-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass_iterator.py
More file actions
35 lines (26 loc) · 940 Bytes
/
class_iterator.py
File metadata and controls
35 lines (26 loc) · 940 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
29
30
31
32
33
34
35
import os
class Iterator:
def __init__(self, name_of_file : str) -> None:
self.name_of_file = name_of_file
self.counter = 0
self.list = []
file = open(self.name_of_file, "r")
for row in file:
self.list.append(row)
file.close()
def __iter__(self):
return self
def __next__(self) -> str:
if self.counter < len(self.list):
tmp = self.list[self.counter]
self.counter += 1
return tmp
else:
raise StopIteration
if __name__ == "__main__":
mark = 4
path_to_dataset = os.path.join( 'application_programming_first_lab_and_dataset','dataset')
folder_path = path_to_dataset + f'\\{mark}'
num_of_files = sum(os.path.isfile(os.path.join(folder_path, f))
for f in os.listdir(folder_path)) + 1
iter = Iterator(num_of_files, mark, folder_path)