Skip to content
Snippets Groups Projects
Commit 66b45cbf authored by Benedikt's avatar Benedikt
Browse files

added xlsx view

parent 734d722c
Branches
Tags
No related merge requests found
from bokeh.models import TabPanel, Tabs,FileInput,CustomJS, Div, Dropdown, MultiChoice
from bokeh.layouts import column
from bokeh.models import TabPanel, Tabs,FileInput, Dropdown
from bokeh.models import ColumnDataSource, DataTable,TableColumn
from bokeh.layouts import column,row
from bokeh.plotting import figure, show, output_file,curdoc
from base64 import b64decode
from io import BytesIO
import pandas as pd
import base64
from openpyxl import load_workbook
import copy
import uuid
tmpSessionID=uuid.uuid4()
sheetNames=[]
controalDict={}
dataDf=pd.DataFrame()
##FileUploadSide
dataXLSFile=None
output_file(filename="custom_filename.html", title="Static HTML file")
import os
dataFileInput = FileInput(title="Select Data files:", accept=".csv,.xls,.xlsx,.odf")
controalFileImput = FileInput(title="Optional select conversion control file:", accept=".json")
sheetSelectDropDown = Dropdown(label="Dropdown button", button_type="warning", menu=sheetNames,disabled=True)
def dataFileUploadCallback(attr, old, new):
data = b64decode(dataFileInput.value)
dataXLSFile=BytesIO(data)
xlsData = b64decode(dataFileInput.value)
dataXLSFile=BytesIO(xlsData)
try:
os.mkdir("./tmp")
except:
pass
try:
os.mkdir("./tmp/"+str(tmpSessionID))
except:
pass
path="./tmp/"+str(tmpSessionID)+'/'+new
with open(path,'wb') as xlsFile:
xlsFile.write(xlsData)
wb = load_workbook(dataXLSFile,'wb')
controalDict['tmpFilePath'] = path
active_ws = wb.active
sheetNames=wb.sheetnames
sheetSelectDropDown.disabled=False
......@@ -40,6 +55,10 @@ def sheetSelectionCallBack(event):
tab2.update(disabled=False)
overAllTabs.active=1# switch to tabel view tab
overAllTabs.update()
dataDf=pd.read_excel(controalDict['tmpFilePath'], controalDict['Sheet'], engine='openpyxl')
data_table.source.data=dataDf
data_table.columns=[TableColumn(field=Ci, title=Ci) for Ci in dataDf.columns]
data_table.update()
print("Test")
......@@ -49,9 +68,14 @@ tab1 = TabPanel(child=column(dataFileInput,controalFileImput,sheetSelectDropDown
###DataViewSide
p2 = figure(width=300, height=300)
p2.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=3, color="navy", alpha=0.5)
tab2 = TabPanel(child=p2, title="TableView",disabled=False)#TODO deactivate as default
data_table = DataTable(
columns=[TableColumn(field=Ci, title=Ci) for Ci in dataDf.columns],
source=ColumnDataSource(dataDf),
height=1050,
width=1680
)
tab2 = TabPanel(child=row(data_table), title="TableView",disabled=False)#TODO deactivate as default
# put the button and plot in a layout and add to the document
overAllTabs=Tabs(tabs=[tab1, tab2])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment