'Convert ppt file to pptx in Python
Is there any way to convert .ppt files to .pptx files.
Objective: I need to extract text from table (with Column Names as Name, address, contact number, email, etc) from .ppt files. For this I followed this approach:
I converted .ppt file to pdf and then extracted the data from pdf using PDFminer. The text extracted from pdf is not separated by any delimiter. Due to this it is very difficult to distinguish names and other fields in the table.
Probable solution I am working on:
- Convert .ppt files to .pptx
- Parse xml of .pptx file to get the formatted text
I am stuck at first step of converting the file format from .ppt to .pptx. I couldn't find any solution for converting .ppt file format to .pptx formt in python.
Solution 1:[1]
I have created this code hope this works for you :
import win32com.client
PptApp = win32com.client.Dispatch("Powerpoint.Application")
PptApp.Visible = True
PPtPresentation = PptApp.Presentations.Open(r'D:\ppt\sample.ppt')
PPtPresentation.SaveAs(r'D:\ppt\final.pptx', 24)
PPtPresentation.close()
PptApp.Quit()
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | piyush kumar |
| Solution 2 | fsfr23 |
