added lab 4

This commit is contained in:
2025-10-31 17:55:13 -04:00
parent dc2ceac7de
commit 88f2975b86
66 changed files with 730 additions and 301 deletions
-41
View File
@@ -1,41 +0,0 @@
from pptx import Presentation
# load the uploaded file
input_path = "./tech_project_proposal_ideas_dark_theme.pptx"
output_path = "./new_pptx.pptx"
def to_title_case(text: str) -> str:
if not text:
return text
# title case for slide titles (major words capitalized)
return text.title()
def to_sentence_case(text: str) -> str:
if not text:
return text
text = text.strip()
if not text:
return text
# sentence case for bullet points
return text[0].upper() + text[1:]
# open ppt
prs = Presentation(input_path)
for slide in prs.slides:
for shape in slide.shapes:
if not shape.has_text_frame:
continue
tf = shape.text_frame
# heuristics: assume first shape (or largest font) in slide is the title
if slide.shapes.index(shape) == 0 or "title" in shape.name.lower():
for para in tf.paragraphs:
para.text = to_title_case(para.text)
else:
for para in tf.paragraphs:
para.text = to_sentence_case(para.text)
# save output
prs.save(output_path)
output_path
Binary file not shown.