Hi!
I need help with reading excel file from dcc.Store
request_file = requests.get(file_url, headers={'X-ACCOUNT-TOKEN': token_k})
url_data = request_file.content
if file_extension == 'csv':
offer_file = pd.read_csv(io.BytesIO(url_data), sep=None, engine='python', keep_default_na=False)
else:
offer_file = pd.ExcelFile(io.BytesIO(url_data))
then i pass str(offer_file) to dcc.Store, and then i need to take it from store → get sheet_names from offer_file and generate dataframe
but i can’t… i don’t know what should i do for properly call pd.read_excel
i’v also tried to encode request_file.content with base64.b64encode - but got error messages:
...
TypeError: Object of type bytes is not JSON serializable
During handling of the above exception, another exception occurred:
...
raise exceptions.InvalidCallbackReturnValue(
dash.exceptions.InvalidCallbackReturnValue: The callback for `[<Output `filename.children`>, <Output `file_keeper.children`>]`
returned a value having type `tuple`
which is not JSON serializable.
The value in question is either the only value returned,
or is in the top level of the returned list,
and has string representation
`('abbc', b'UEsDBAoAAAAAAIdO4kAAAAAAAAAAAAAAAAAJAAAAZG9jUHJvcHMvU...`)
In general, Dash properties can only be
dash components, strings, dictionaries, numbers, None,
or lists of those.
the solution was:
base64.b64encode(request_file.content).decode('utf-8')