Xi12
Xi12

Reputation: 1223

Alternative to st.file_uploader Snowflake Streamlit

I'm working on developing an app using Streamlit where users can upload a CSV file and insert it into a table or display its contents . I've attempted to use st.file_uploader, but it seems to be disabled. In my use case, users should have the option to upload a CSV file either from their local machine or from my S3 bucket. Could you please provide alternative approaches to implement this functionality?

Thanks

Upvotes: 2

Views: 2113

Answers (3)

Lukasz Szozda
Lukasz Szozda

Reputation: 176064

Streamlit in Snowflake(version 9.2) supports st.file_uploader component.

import streamlit as st
from snowflake.snowpark.context import get_active_session

session = get_active_session()
st.text("Current version:"+session.sql('select current_version()').collect()[0][0])

uploaded_file = st.file_uploader("Choose a file")

Output:

enter image description here

More at: Support for st.file_uploader - Preview

Upvotes: 1

Praveen kumar
Praveen kumar

Reputation: 1

You can build the Streamlit app running in snowflake container services and achieve the same

Upvotes: 0

Michael Golos
Michael Golos

Reputation: 2069

To be precise, the Streamlit file_uploader control works correctly in applications outside Snowflake. For now it is blocked in Streamlit in Snowflake (SiS) for security reasons, in the future Snowflake should enable it (I'm also waiting very much for that).

You can find the full list of limitations in SiS here: Unsupported Streamlit in Snowflake features

At the moment there are two possibilities:

  1. Using Streamlit outside Snowflake.
  2. Allowing users to upload files to the S3 bucket (e.g., using AWS Explorer) and in the SiS application reading the file from this external stage, instead of uploading it via the file_uploader control.

Upvotes: 1

Related Questions