Load data from the uploaded file based on its extension.
(uploaded_file)
| 376 | |
| 377 | @st.cache_data() |
| 378 | def load_data(uploaded_file): |
| 379 | """ |
| 380 | Load data from the uploaded file based on its extension. |
| 381 | """ |
| 382 | try: |
| 383 | ext = os.path.splitext(uploaded_file.name)[1][1:].lower() |
| 384 | except: |
| 385 | ext = uploaded_file.split(".")[-1] |
| 386 | if ext in file_formats: |
| 387 | return file_formats[ext](uploaded_file) |
| 388 | else: |
| 389 | st.error(f"Unsupported file format: {ext}") |
| 390 | return None |
| 391 | |
| 392 | st.title("Chat with your dataset") |
| 393 | st.info("Asking one question at a time will result in a better output") |