Kushwanth Chowday Kandala commited on
Commit
7d43644
1 Parent(s): 792de2f

string based IO output

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -143,6 +143,18 @@ with st.sidebar:
143
  """)
144
  uploaded_files = st.file_uploader('Choose your .pdf file', type="pdf", accept_multiple_files=True)
145
  for uploaded_file in uploaded_files:
146
- bytes_data = uploaded_file.read()
147
- st.write("filename:", uploaded_file.name)
148
- st.write(bytes_data)
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  """)
144
  uploaded_files = st.file_uploader('Choose your .pdf file', type="pdf", accept_multiple_files=True)
145
  for uploaded_file in uploaded_files:
146
+ # To read file as bytes:
147
+ # bytes_data = uploaded_file.getvalue()
148
+ # st.write(bytes_data)
149
+
150
+ # To convert to a string based IO:
151
+ stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
152
+ st.write(stringio)
153
+
154
+ # To read file as string:
155
+ # string_data = stringio.read()
156
+ # st.write(string_data)
157
+
158
+ # Can be used wherever a "file-like" object is accepted:
159
+ # dataframe = pd.read_csv(uploaded_file)
160
+ # st.write(dataframe)