Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textract failure #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions zodo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,13 @@ def download_supplemental(raw_json):
def extract_text_from_files(pmcdir):
supp_files = [x for x in listdir(pmcdir) if x.split(".")[-1] in SUPPLEMENTAL_DATA_FILETYPES]
logging.debug("Files for extraction in %s : %s", pmcdir, ",".join(supp_files))
# For now just extract all text the same way using textract
supp_file_contents = {x:str(textract.process(join(pmcdir, x))).replace("\\n", "\n") for x in supp_files}
# For now just extract all text the same way using textract (textract may fail)
supp_file_contents = {}
for suppfile in supp_files:
try:
supp_file_contents[suppfile] = str(textract.process(join(pmcdir, suppfile))).replace("\\n", "\n")
except Exception as e:
logging.error("Error in textract: %s", e)
supp_contents = ""
for suppfile, content in supp_file_contents.items():
supp_contents += "\n\n*** " + str(suppfile) + " ***\n" + str(content)
Expand Down