Skip to content

Commit

Permalink
Update VisualQC.py
Browse files Browse the repository at this point in the history
Added xls and csv management
  • Loading branch information
PythonOpenProjects authored May 10, 2024
1 parent d9a62ee commit a7314a8
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions VisualQC.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
'''
https://github.com/ragardner/tksheet/wiki#24-example-loading-data-from-excel
https://github.com/ragardner/tksheet
Expand All @@ -23,7 +24,8 @@

from ttkthemes import ThemedTk
from tkinter import messagebox

import uuid
import time



Expand Down Expand Up @@ -89,16 +91,27 @@ def esegui():

actualdirname = os.getcwd()
name = askopenfilename(initialdir=actualdirname,
filetypes =(("XLSX", "*.xlsx"),("All Files","*.*")),
filetypes =(("XLSX", "*.xlsx"),("XLS", "*.xls"),("CSV","*.csv"),("All Files","*.*")),
title = "Choose a file."
)


sheet = Sheet(LabelFrameXls,
data = pd.read_excel(name, # filepath here
#sheet_name = "sheet1", # optional sheet name here
engine = "openpyxl",
header = None).values.tolist())
if name.endswith('.csv'):
read_file = pd.read_csv(name)
idrnd = uuid.uuid4()
tempExcel=str(time.strftime("%Y%m%d%H%M%S")+'-'+str(idrnd)+'.xlsx')
read_file.to_excel(tempExcel, index=False, header=True)
sheet = Sheet(LabelFrameXls,
data = pd.read_excel(tempExcel, # filepath here
#sheet_name = "sheet1", # optional sheet name here
engine = "openpyxl",
header = None).values.tolist())
else:
#df = pd.read_csv(name)
sheet = Sheet(LabelFrameXls,
data = pd.read_excel(name, # filepath here
#sheet_name = "sheet1", # optional sheet name here
engine = "openpyxl",
header = None).values.tolist())

sheet.enable_bindings("all")

Expand Down Expand Up @@ -496,7 +509,7 @@ def printnvar():
SpacelQCInfo = Label(LabelFrameInfo, text =" ")
SpacelQCInfo.grid(row=0, column=0, sticky=W)

openInputFileButton = Button(LabelFrameInfo, text="Select file (only XLSX files)",bg = "moccasin", command=(esegui))
openInputFileButton = Button(LabelFrameInfo, text="Select file (XLSX, XLS, CSV)",bg = "moccasin", command=(esegui))
openInputFileButton.grid(row=1, column=1, sticky=W)

SpacelQCInfoBis = Label(LabelFrameInfo, text =" ")
Expand Down

0 comments on commit a7314a8

Please sign in to comment.