Python Pandas in Workflow - Parsing Excel in Retool Storage

Hi @Adam_Cogswell,

I wonder if a solution similar to what @Darren is doing here would work, but with Python. Maybe something like this?

import base64
import pandas as pd
import io

# Assuming you have a base64 string representation of the Excel file
# Replace this with the actual base64 encoded content
base64_data = file_input_base64_data # Define your base64 file input here

# Decode the base64 data
decoded_data = base64.b64decode(base64_data)

# Use pandas to read the Excel content
# Use io.BytesIO to treat the decoded data as a file object
excel_data = pd.read_excel(io.BytesIO(decoded_data), sheet_name=0)

# Convert the data to JSON format
json_data = excel_data.to_json(orient='records')

# Display or return the JSON data
print(json_data)

I'll do some testing on my end as well for your setup, but sharing this in the interim.

2 Likes