RetreivalData / app.py
TarunEnma's picture
Update app.py
da79f7c verified
raw
history blame
552 Bytes
import streamlit as st
class TextLoader:
def __init__(self, file):
self.file = file
def load(self):
return self.file.read().decode("utf-8")
st.title("Please upload files that are txt format")
uploaded_file = st.file_uploader("Choose a text file", type=["txt"])
if uploaded_file is not None:
with open("uploaded_file.txt", "wb") as f:
f.write(uploaded_file.getbuffer())
text_loader = TextLoader(open("uploaded_file.txt","rb"))
file_content = text_loader.load()
# st.write("File content:")
# st.text(file_content)