HELP Python & Streamlit

Hi
Can someone help me?
I’m trying to create the following with Pyton & Streamlit:
In Streamlit I should be able to enter a place name and then it should show the zip code. The basis for this is a CSV file with all postcodes in Switzerland.
Can someone help me how to do this best?

Hello:

Below is my approach:

  1. Store the CSV using Pandas.
  2. Get input from the user (place)
  3. On clicking a button-the search function kicks in.
  4. On success, display the zipcode. Else an error message something like “Zipcode not found”.

Thanks !!!

Hello:

Please find the below python code:

import pandas as pd
import streamlit as st
df=pd.read_csv(r’replace with your file’)
st.dataframe(df)
x=st.text_input(“Enter the Pincode”)
def fn():
for index, row in df.iterrows():
if(int(row[‘PinCode’])==int(x)):
y=row[‘Name’]
break
else:
y=‘Error’
return(y)
if name==“main”:
y1=fn()
st.write(y1)

Sample Output:

image

Can you modify your code as above. (indentation is missing in yours)

Hi @mr_swiss,

Please refrain from asking other community members to build your app. We’d love to help you build it! But asking others to write your entire app takes away all the fun :slightly_smiling_face:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.