-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20.CSVConv.py
41 lines (29 loc) · 1.43 KB
/
20.CSVConv.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
import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox
import pandas as pd
root= tk.Tk()
canvas1 = tk.Canvas(root, width = 300, height = 300, bg = 'lightsteelblue2', relief = 'raised')
canvas1.pack()
label1 = tk.Label(root, text='Text to CSV', bg = 'lightsteelblue2')
label1.config(font=('helvetica', 20))
canvas1.create_window(150, 60, window=label1)
def getTxt ():
global read_file
import_file_path = filedialog.askopenfilename()
read_file = pd.read_csv(import_file_path)
browseButtonTxt = tk.Button(text=" Import Text File ", command=getTxt, bg='green', fg='white', font=('helvetica', 12, 'bold'))
canvas1.create_window(150, 130, window=browseButtonTxt)
def convertToCsv ():
global read_file
export_file_path = filedialog.asksaveasfilename(defaultextension='.csv')
read_file.to_csv (export_file_path, index = None)
saveAsButtonCsv = tk.Button(text='Convert Text to CSV', command=convertToCsv, bg='green', fg='white', font=('helvetica', 12, 'bold'))
canvas1.create_window(150, 180, window=saveAsButtonCsv)
def exitApplication():
MsgBox = tk.messagebox.askquestion ('Exit the application',icon = 'warning')
if MsgBox == 'yes':
root.destroy()
exitButton = tk.Button (root, text=' Exit Application ',command=exitApplication, bg='brown', fg='white', font=('helvetica', 12, 'bold'))
canvas1.create_window(150, 230, window=exitButton)
root.mainloop()