-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (35 loc) · 1.44 KB
/
main.py
File metadata and controls
39 lines (35 loc) · 1.44 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
from utils import format_csv, get_root, xml_to_csv, xml_handler
from menu import init_menu, handle_menu_event
from custom_io import read_csv
if __name__ == '__main__':
print("Welcome to CSV formatter, if you have problems using this tool, visit: "
"https://github.com/fatihozkan-github/csv_formatter")
while True:
show_menu = False
use_tool = False
print('Add your csv file to project directory. When you are ready, insert filename below. '
'You can also drag your file here.\n'
'If you want to use XML to CSV tool leave empty.')
given_file_name = input('File name: ')
if given_file_name == "":
use_tool = True
root_path = get_root(given_file_name)
row_list = []
try:
row_list = read_csv(file_name=given_file_name)
row_list = format_csv(row_list)
show_menu = True
except (Exception,):
if given_file_name != "":
print("No such file or directory. Check your file location & name.")
show_menu = False
while use_tool:
xml_handler()
while show_menu:
index = 0
init_menu()
try:
index = int(input('Enter your choice: '))
except(Exception,):
print("Invalid input, please enter an int value.")
handle_menu_event(index, row_list, root_path=root_path)