Skip to content

Commit 626bdbe

Browse files
committed
Fix uploadfile.read() empty bug
1 parent 04ccce6 commit 626bdbe

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app_doctr.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import streamlit as st
1313

1414
from msfocr.data import dhis2
15-
from msfocr.data import ocr_functions
15+
from msfocr.doctr import ocr_functions
1616

1717
def configure_secrets():
1818
"""Checks that necessary environment variables are set for fast failing.
@@ -156,7 +156,12 @@ def get_uploaded_images(tally_sheet):
156156
:param Files uploaded by user
157157
:return List of images uploaded by user as docTR DocumentFiles
158158
"""
159-
return [DocumentFile.from_images(sheet.read()) for sheet in tally_sheet]
159+
res = []
160+
for sheet in tally_sheet:
161+
sheet.seek(0, 0)
162+
image = sheet.read()
163+
res.append(DocumentFile.from_images(image))
164+
return res
160165

161166
@st.cache_data
162167
def get_results(uploaded_images):
@@ -292,14 +297,15 @@ def get_period():
292297
if 'table_dfs' in st.session_state:
293298
del st.session_state['table_dfs']
294299
st.rerun()
295-
300+
296301
uploaded_images = get_uploaded_images(tally_sheet)
297302
results = get_results(uploaded_images)
298303

299304
### CORRECT THIS TO ALLOW PROCESSING OF ALL IMAGES
300305
# ***************************************
301306
image = uploaded_images[0]
302307
result = results[0]
308+
print(result)
303309
# ***************************************
304310

305311
# form_type looks like [dataSet, orgUnit, period=[startDate, endDate]]

0 commit comments

Comments
 (0)