Create file_uploader.py

This commit is contained in:
op07n 2020-01-21 07:57:13 +01:00 committed by GitHub
parent b064e23f23
commit 49c9ab2c96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 0 deletions

38
apps/file_uploader.py Normal file
View File

@ -0,0 +1,38 @@
import streamlit as st
import pandas as pd
st.title("File uploader example")
st.write(
"""
This is an example of how to use a file uploader.
Here, we are simply going to upload a CSV file and display it.
It should serve as a minimal example
for you to jump off and do more complex things.
"""
)
st.header("Upload CSV")
csv_file = st.file_uploader(
label="Upload a CSV file", type=["csv"], encoding="utf-8"
)
if csv_file is not None:
data = pd.read_csv(csv_file)
st.dataframe(data)
st.header("Upload Images")
st.write(
"""
Below is another example, where we upload an image and display it.
"""
)
image_file = st.file_uploader(
label="Upload an image", type=["png", "jpg", "tiff"], encoding=None
)
if image_file is not None:
st.image(image_file)