from pptx import Presentation
from lxml import etree
from copy import deepcopy
prs=Presentation("/tmp/sesion_bni.pptx")
slide=prs.slides[112]
ns={"a":"http://schemas.openxmlformats.org/drawingml/2006/main"}
for shape in slide.shapes:
 if not shape.has_table:continue
 t=shape.table
 nr=len(list(t.rows));nc=len(t.columns)
 # Copy XML of rows 2-6 into rows 1-5
 for ri in range(1,nr-1):
  for ci in range(nc):
   src=t.cell(ri+1,ci);dst=t.cell(ri,ci)
   src_txBody=src._tc.find("a:txBody",ns)
   dst_tc=dst._tc
   old_txBody=dst_tc.find("a:txBody",ns)
   new_txBody=deepcopy(src_txBody)
   dst_tc.replace(old_txBody,new_txBody)
 # Last row: copy XML from row above, change text
 nd=["05 de Mayo","Miguel Varela","Silvia Burkle","21 de Abril"]
 for ci in range(nc):
  src=t.cell(nr-2,ci);dst=t.cell(nr-1,ci)
  src_txBody=src._tc.find("a:txBody",ns)
  dst_tc=dst._tc
  old_txBody=dst_tc.find("a:txBody",ns)
  new_txBody=deepcopy(src_txBody)
  # Change text
  at=new_txBody.find(".//a:t",ns)
  at.text=nd[ci]
  dst_tc.replace(old_txBody,new_txBody)
 break
prs.save("/tmp/out2.pptx")
print("Saved!")
# Verify
p2=Presentation("/tmp/out2.pptx")
for s in p2.slides[112].shapes:
 if s.has_table:
  for ri,row in enumerate(s.table.rows):
   print(f"Row {ri}: {[c.text.strip() for c in row.cells]}")
