Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (50.2k points)
There are records in ppt or pptx, and I want to obtain them as data.frames in R. Any solutions? Thanks.

I know that we can turn ppt(x) to pdf in R and extract them using other packages. Any packages to turn ppt to pdf?

1 Answer

0 votes
by (108k points)

I know code in python but you can easily convert it in R programming:

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_table:

            continue    

        tbl = shape.table

        row_count = len(tbl.rows)

        col_count = len(tbl.columns)

        for r in range(0, row_count):

            for c in range(0, col_count):

                cell = tbl.cell(r,c)

                paragraphs = cell.text_frame.paragraphs 

                for paragraph in paragraphs:

                    for run in paragraph.runs:

                        text_runs.append(run.text)

print(text_runs)```

Related questions

Browse Categories

...