-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask1.py
More file actions
18 lines (15 loc) · 793 Bytes
/
task1.py
File metadata and controls
18 lines (15 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
import csv
def create_csv_annotation(class_name: str, annotation_name: str) -> None:
'''This function create csv annotation with 3 parameters: absolute path to file, relative path and file's class name'''
path_to_class = os.path.join('dataset', class_name)
class_names = os.listdir(path_to_class)
with open(annotation_name, mode="w", encoding="UTF-16", newline='') as file:
file_writer = csv.writer(file, delimiter=",")
for name in class_names:
file_writer.writerow(
[os.path.abspath(name), os.path.join(path_to_class, name), class_name])
# first task
def run1(class_name: str, annotation_name: str) -> None:
''' This function call previous to run it in main'''
create_csv_annotation(class_name, annotation_name)