I don’t quite understand why using a function to read a CSV file would fail
or Sometimes it may not be able to read column names.
This is my code:
import streamlit as st
import pandas as pd
file = st.file_uploader("upload:")
def read_data(filename):
df = pd.read_csv(filename, encoding='gbk')
return df
if file:
st.subheader("1")
df1 = pd.read_csv(file, encoding="gbk")
st.write(df1)
st.subheader("2")
df = read_data(file) # st.write(pd.read_csv(file, encoding="gbk"))
st.write(df)
