Reputation: 625
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?
Upvotes: 3
Views: 25941
Reputation: 55
You may check Apache Tika because I use it on mac like this
For MacOS Homebrew users: install Apache Tika (brew install tika
)
The command-line interface works like this:
tika --text something.ppt > something.txt
And to use it inside python script:
import os
os.system("tika --text temp.ppt > temp.txt")
You will be able to do it and that is the only solution I have so far.
Upvotes: -1
Reputation: 1694
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)
Upvotes: 3
Reputation: 625
Using catdoc/catppt with subprocess to open doc files and ppt files.
Upvotes: 0
Reputation: 108
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
Upvotes: 1
Reputation: 174624
Use odf.opendocument.OpenDocumentPresentation from the odfpy project. This is assuming you are only concerned with recent format files, that are compatible with the OpenDocument standard.
If you have access to OpenOffice, you can use their Python api to read the file.
Upvotes: 1