-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (29 loc) · 988 Bytes
/
Copy pathmain.py
File metadata and controls
36 lines (29 loc) · 988 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
36
import pandas as pd
class Event:
def __init__(self):
self.value = Event.get_file_name()
Event.main(self.value)
def main(csv_file):
try:
df = pd.read_csv(f'csv_files\{csv_file}.csv', delimiter=';', encoding='ISO-8859-1', )
except (FileNotFoundError):
print('File not found')
exit()
yn = input("Have header? (y/n): ")
while True:
if yn == 'y' or yn == 'Y':
df.to_excel(f'xlsx_files\{csv_file}.xlsx', index=None, header=True)
elif yn == 'n' or yn == 'N':
df.to_excel(f'xlsx_files\{csv_file}.xlsx', index=None, header=False)
else:
break
def get_file_name():
while True:
value = input('Enter file name: ')
if value == '':
print('File name is empty')
else:
break
return value
if __name__ == '__main__':
Event()