I am using streamlit for displaying a dropdown menu based on a csv list (symbols.csv).
This is how the csv list looks:
This is the code I am writing:
def choosing_asset(): with open('symbols.csv', newline='') as f: reader = csv.reader(f) data = list(reader) option = st.sidebar.selectbox('Select your asset',data) name = option ticker = option return(name,ticker)
And this is how streamlit is displaying the dropdownmenu:
I would like to remove those brackets and quotes from the dropdownmenu, I would like to show only in the format “Bitcoin, BTC-USD” like in the csv file.
Thanks in advance
You have nested list like this
data = [ ['Bitcoin', 'BTC-USD'], ['Ethereum', 'ETH-USD'] ]
and you have to convert sublists to strings using ie.
data = [','.join(row) for row in data]
Or you should read it as normal text file
with open('symbols.csv', newline='') as f: data = list(f) data = [line.strip() for line in data]
with open('symbols.csv', newline='') as f: data = f.read().splitlines()
And if you want to skip first row with
data = data[1:]