Spaces:
Runtime error
Runtime error
# import s3fs | |
from io import StringIO | |
import pandas as pd | |
import boto3 | |
from bokeh.models.widgets import Div | |
import streamlit as st | |
def get_files_from_aws(bucket,prefix): | |
""" | |
get files from aws s3 bucket | |
bucket (STRING): bucket name | |
prefix (STRING): file location in s3 bucket | |
""" | |
s3_client = boto3.client('s3', | |
aws_access_key_id = st.secrets["aws_id"], | |
aws_secret_access_key = st.secrets["aws_key"]) | |
file_obj = s3_client.get_object(Bucket=bucket,Key=prefix) | |
body = file_obj['Body'] | |
string = body.read().decode('utf-8') | |
df = pd.read_csv(StringIO(string)) | |
return df | |
def url_button(button_name,url): | |
if st.button(button_name): | |
js = """window.open('{url}')""".format(url=url) # New tab or window | |
html = '<img src onerror="{}">'.format(js) | |
div = Div(text=html) | |
st.bokeh_chart(div) | |