I want to open a ppt file using Python on linux, (like python open a .txt file). I know win32com, but I am working on linux. So, What do I need to do?
python-pptx can open recent Powerpoint versions on Linux. They even provide an example for extracting all text from slides in their Getting started guide.
Here's the code (from the Getting Started guide)
from pptx import Presentation
prs = Presentation(path_to_presentation)
# text_runs will be populated with a list of strings,
# one for each text run in presentation
text_runs = []
for slide in prs.slides:
for shape in slide.shapes:
if not shape.has_textframe:
continue
for paragraph in shape.textframe.paragraphs:
for run in paragraph.runs:
text_runs.append(run.text)
If you are on Linux, what office software are you referring to. OpenOffice (headless) can be interfaced using python on Linux. Here is a nice example https://github.com/jledoux/FRIEDA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With