Skip to content

Instantly share code, notes, and snippets.

@mashu3
Created March 15, 2022 13:49
python-pptxの使用例
import pptx
def pptx2text(file_path):
texts = [] # 抽出したテキストデータを格納する空リスト
prs = pptx.Presentation(file_path)
# スライドごとにテキストデータを抽出する
for sld in prs.slides:
for shape in sld.shapes:
# shapeに含まれるテキストデータを抽出
if shape.has_text_frame:
for text in shape.text.splitlines():
texts.append(text)
# tableに含まれるテキストデータを抽出
if shape.has_table:
for cell in shape.table.iter_cells():
for text in cell.text.splitlines():
texts.append(text)
return texts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment