-
Notifications
You must be signed in to change notification settings - Fork 11
/
app.py
31 lines (23 loc) · 923 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import streamlit as st
import pandas as pd
import json
import snowflake.snowpark as snowpark
from snowflake.snowpark import Session, DataFrame
import utils as u
# connect to Snowflake
with open('../creds.json') as f:
connection_parameters = json.load(f)
session = Session.builder.configs(connection_parameters).create()
def loadInferAndPersist(file) -> snowpark.DataFrame:
file_df = pd.read_csv(file)
snowparkDf=session.write_pandas(file_df,file.name,auto_create_table = True, overwrite=True)
return snowparkDf
st.header("Grandma data uploader")
file = st.file_uploader("Drop your CSV here", type={"csv"})
if file is not None:
df= loadInferAndPersist(file)
st.subheader("Great, your data has been uploaded to Snowflake!")
with st.expander("Technical information"):
u.describeSnowparkDF(df)
st.write("Data loaded to Snowflake:")
st.dataframe(df)