code: def doc_reader(infile):
      
      if infile.endswith('.docx'):
          docid = 'word/document.xml'
      else:
          docid = 'content.xml'
      try:
          zfile = zipfile.ZipFile(infile)
      except:
          print('Sorry, can\'t open {}.'.format(infile))
          return
      body = ET.fromstring(zfile.read(docid))
      text = '\n'.join([et.text.strip() for et in body.iter() if et.text])
      return text
docs: Parse docx and odf files.