restructure
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import streamlit as st
|
||||
|
||||
from utils.df_utils import to_excel_binary, to_hdf_binary
|
||||
from utils.df2bin import to_excel_binary, to_hdf_binary
|
||||
|
||||
|
||||
state = st.session_state
|
||||
|
@ -1,6 +1,6 @@
|
||||
import cherrypy as cp
|
||||
|
||||
from utils.df_utils import DateFrameHolder
|
||||
from utils.dfh import DateFrameHolder
|
||||
from utils.st_utils import rerun
|
||||
|
||||
|
||||
|
27
utils/df2bin.py
Normal file
27
utils/df2bin.py
Normal file
@ -0,0 +1,27 @@
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
def to_excel_binary(df, **kwargs):
|
||||
with BytesIO() as out:
|
||||
df.to_excel(out, **kwargs)
|
||||
res = out.getvalue()
|
||||
return res
|
||||
|
||||
|
||||
|
||||
from pandas import HDFStore
|
||||
|
||||
|
||||
def to_hdf_binary(df):
|
||||
with HDFStore(
|
||||
"wontbewritten.h5",
|
||||
mode="a",
|
||||
driver="H5FD_CORE",
|
||||
driver_core_backing_store=0
|
||||
) as out:
|
||||
out["/data"] = df
|
||||
res = out._handle.get_file_image()
|
||||
return res
|
||||
|
||||
|
||||
|
@ -45,30 +45,3 @@ def dump_non_empty_df(df, fn, key="data"):
|
||||
|
||||
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
def to_excel_binary(df, **kwargs):
|
||||
with BytesIO() as out:
|
||||
df.to_excel(out, **kwargs)
|
||||
res = out.getvalue()
|
||||
return res
|
||||
|
||||
|
||||
|
||||
from pandas import HDFStore
|
||||
|
||||
|
||||
def to_hdf_binary(df):
|
||||
with HDFStore(
|
||||
"wontbewritten.h5",
|
||||
mode="a",
|
||||
driver="H5FD_CORE",
|
||||
driver_core_backing_store=0
|
||||
) as out:
|
||||
out["/data"] = df
|
||||
res = out._handle.get_file_image()
|
||||
return res
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user