Created
September 7, 2021 17:46
-
-
Save mkhorasani/82126d02166fbe6e26b494a443c75341 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def file_upload(name): | |
uploaded_file = st.sidebar.file_uploader('%s' % (name),key='%s' % (name),accept_multiple_files=False) | |
content = False | |
if uploaded_file is not None: | |
try: | |
uploaded_df = pd.read_csv(uploaded_file) | |
content = True | |
return content, uploaded_df | |
except: | |
try: | |
uploaded_df = pd.read_excel(uploaded_file) | |
content = True | |
return content, uploaded_df | |
except: | |
st.error('Please ensure file is .csv or .xlsx format and/or reupload file') | |
return content, None | |
else: | |
return content, None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment