Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pyDCCandDBTools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benedikt
pyDCCandDBTools
Commits
66b45cbf
Commit
66b45cbf
authored
2 years ago
by
Benedikt
Browse files
Options
Downloads
Patches
Plain Diff
added xlsx view
parent
734d722c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DCCTableTool.py
+35
-11
35 additions, 11 deletions
DCCTableTool.py
with
35 additions
and
11 deletions
DCCTableTool.py
+
35
−
11
View file @
66b45cbf
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
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment