def doc_reader(infile):
if infile.endswith('<STR_LIT>'):<EOL><INDENT>docid = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>docid = '<STR_LIT>'<EOL><DEDENT>try:<EOL><INDENT>zfile = zipfile.ZipFile(infile)<EOL><DEDENT>except:<EOL><INDENT>print('<STR_LIT>'.format(infile))<EOL>return<EOL><DEDENT>body = ET.fromstring(zfile.read(docid))<EOL>text = '<STR_LIT:\n>'.join([et.text.strip() for et in body.iter() if et.text])<EOL>return text<EOL>
Parse docx and odf files.