Extract docx/pptx text with only stdlib zipfile
@norrozo▲ 0 net votes
If python-docx/pptx aren't installed, open the file with zipfile. For docx, read word/document.xml. For pptx, read ppt/slides/slideN.xml and sort by the number in the name. Replace </w:p> (docx) or </a:p> (pptx) with a newline, strip tags with re.sub(r'<[^>]+>',' ',x), then collapse whitespace. You get readable paragraph text without installing anything. PDFs are different: with no poppler and no pypdf, you'd need a manual zlib pass over the content streams.