This week’s challenge is another Streamlit challenge, we want you to produce an interface where you can upload files into whichever table is selected.
You will find your setup code here
create schema <enter_db_name_here>.world_bank_metadata; create or replace table <enter_db_name_here>.world_bank_metadata.country_metadata ( country_code varchar(3), region string, income_group string ); create schema <enter_db_name_here>.world_bank_economic_indicators; create or replace table <enter_db_name_here>.world_bank_economic_indicators.gdp ( country_name string, country_code varchar(3), year int, gdp_usd double ); create table <enter_db_name_here>.world_bank_economic_indicators.gov_expenditure ( country_name string, country_code varchar(3), year int, gov_expenditure_pct_gdp double ); create schema <enter_db_name_here>.world_bank_social_indiactors; create or replace table <enter_db_name_here>.world_bank_social_indiactors.life_expectancy ( country_name string, country_code varchar(3), year int, life_expectancy float ); create or replace table <enter_db_name_here>.world_bank_social_indiactors.adult_literacy_rate ( country_name string, country_code varchar(3), year int, adult_literacy_rate float ); create or replace table <enter_db_name_here>.world_bank_social_indiactors.progression_to_secondary_school ( country_name string, country_code varchar(3), year int, progression_to_secondary_school float );
Unfortunately, basic Python knowledge is essential for this week. But, it’s nothing a quick beginner’s course couldn’t quickly teach you!
You can find the data here, and the FF logo here.
Remember if you want to participate:
- Sign up as a member of Frosty Friday. You can do this by clicking on the sidebar, and then going to ‘REGISTER‘ (note joining our mailing list does not give you a Frosty Friday account)
- Post your code to GitHub and make it publicly available (Check out our guide if you don’t know how to here)
- Post the URL in the comments of the challenge.
You can also sign up to our mailing list below.
Interesting, it taught me a lot.
Solution URL – https://github.com/mateusz-kmon/frostyfridaychallenges/blob/main/w12.py
I was delayed this time due to a busy weekend, however this was a fun challenge to come back to!
I cheekily replaced the logo with the IW one, but other than this I think my solution matches the brief. I chose to leverage Snowpark to directly write the Pandas dataframes for the uploaded files into the tables in Snowflake, which was also fun.
A lot of lessons learned today…
1. use a dbt model to create the tables needed
2. create the streamlit app
– hardcode schemas
– retrieve tables from information_schema
– file uploader
– show a preview of the data
– submit to upload to SF and show the response if successful
Took me a looong time to get the “write pandas” to work
Pekka Kanerva says
Very nice challenge, it was quite easy to build this useful small app with Streamlit!
Given a bit of twist. Have provided user selection for database as well, along with schema and table