To create a basic search engine using Streamlit for filtering records from a CSV file with 5 columns, you can follow these steps:
search_engine.py
) and add the following code:
In this code:
streamlit
and pandas
.load_data
function is defined to read the CSV file using pd.read_csv()
. The @st.cache
decorator is used to cache the data, which improves the app's performance by loading the data only once.data
variable stores the loaded CSV data.st.title('Search Engine')
, which sets the app's title.st.sidebar.text_input('Enter search term:', '')
.apply
method. This line of code checks if the search term appears in any cell of each row.filtered_data
variable.st.write()
. We also show the count of matching records using len(filtered_data)
.'your_data.csv'
:'your_data.csv'
with the actual path to your CSV file. Make sure the CSV file is in the same directory as your script, or provide the full path.This basic Streamlit script creates a simple search engine for your CSV data. Users can input a search term, and the script will filter and display matching records.