Extracting text from multiple powerpoint files using python
<p>I am trying to find a way to look in a folder and search the contents of all of the powerpoint documents within that folder for specific strings, preferably using Python. When those strings are found, I want to report out the text after that string as well as what document it was found in. I would like to compile the information and report it in a CSV file. </p>

<p>So far I've only come across the olefil package, <a href="https://bitbucket.org/decalage/olefileio_pl/wiki/Home" rel="nofollow">https://bitbucket.org/decalage/olefileio_pl/wiki/Home</a>. This provides all of the text contained in a specific document, which is not what I am looking to do. Please help.</p>

<p><code>python-pptx</code> can be used to do what you propose. Just at a high level, you would do something like this (not working code, just and idea of overall approach):</p>

<pre><code>from pptx import Presentation

for pptx_filename in directory:
    prs = Presentation(pptx_filename)
    for slide in prs.slides:
        for shape in slide.shapes:
            print shape.text
</code></pre>

<p>You'd need to add the bits about searching shape text for key strings and adding them to a CSV file or whatever, but this general approach should work just fine. I'll leave it to you to work out the finer points :)</p>

python python-2.7 powerpoint