Can I filter csv files based on values and display result ?
Yup!
Since Streamlit is just a Python library, you can use the full power of any other Python libraries in your Streamlit apps.
For instance, here’s an example of how to use Streamlit with Pandas to load and filter a CSV file:
import streamlit as st
import pandas as pd
@st.cache
def get_data():
return pd.read_csv('https://datahub.io/core/gdp/r/gdp.csv')
'# World GDP'
df = get_data()
min_year = int(df['Year'].min())
max_year = int(df['Year'].max())
countries = df['Country Name'].unique()
'## By country'
country = st.selectbox('Country', countries)
df[df['Country Name'] == country]
'## By year'
year = st.slider('Year', min_year, max_year)
df[df['Year'] == year]
If you want to try out the code above without copying it into a file, just run this command on your terminal:
streamlit run https://gist.githubusercontent.com/tvst/713f5804ab45b9430866ee639d8568f1/raw/96726dc3b5e09933dbabd7790abbdf8b435df4fb/streamlit_csv_example.py
Awesome ! Another quick question how do we display images say that there is a path mentioned in the filtered list and I want to display 1 image at a time say the returned images is 1000. Is there a widget for the same where I can click next or something and it will display images one by one ?
Hi @yshvrdhn: I know that you know this, but for other users coming in, this thread provides various solutions to this pagination question. Thanks for all the questions!