BASE="/tmp/workspace/attachments/06b69cab-24b9-4468-9b88-4a9905b33ea9" python3 << 'EOF' import pdfplumber, os, json base = "/tmp/workspace/attachments/06b69cab-24b9-4468-9b88-4a9905b33ea9" pdfs = [ "E. Levy - Functional constipation in children challenges and solutions [2017].pdf", "WJG-22-567.pdf", "L. Lladó - Techniques of orthotopic liver transplantation. [2004].pdf", "Preventing Muscle Loss.pdf", "R. Poon - Hepatectomy for hepatocellular carcinoma Patient selection and postoperative outcome [2004].pdf", "s00423-020-01960-6.pdf", "R. Poon - Current techniques of liver transection. [2007].pdf", "B. Regmi - An Overview of Current Status, Recent Techniques and Challenges of Liver Transplantation [2018].pdf", "G. Rubin - Chronic constipation in children [2006].pdf", ] results = {} for pdf in pdfs: path = os.path.join(base, pdf) try: with pdfplumber.open(path) as doc: pages = len(doc.pages) # Extract first 6 pages for summary (enough for abstract, intro, methods, results, conclusion) text = "" for i, page in enumerate(doc.pages): if i >= 8: break t = page.extract_text() if t: text += t + "\n\n--- PAGE BREAK ---\n\n" results[pdf] = {"pages": pages, "text": text[:8000]} # cap at 8000 chars except Exception as e: results[pdf] = {"pages": 0, "text": f"ERROR: {e}"} # Save to tmp with open("/tmp/pdf_extracts.json", "w") as f: json.dump(results, f) print("Done. Files processed:", list(results.keys())) for k,v in results.items(): print(f"\n=== {k} === pages={v['pages']}, text_len={len(v['text'])}") print(v['text'][:300]) print("...") EOF
ls -la "/tmp/workspace/attachments/" && echo "---" && ls -la "/tmp/workspace/attachments/06b69cab-24b9-4468-9b88-4a9905b33ea9/" 2>/dev/null || echo "Directory not found"
find /tmp -name "*.pdf" 2>/dev/null | head -30 && echo "---" && ls /tmp/workspace/ 2>/dev/null || echo "workspace not found"
ls / && echo "---" && ls /tmp/ 2>/dev/null
ls /tmp/workspace/ && echo "---" && ls /workspace/ 2>/dev/null && echo "---" && find /workspace -name "*.pdf" 2>/dev/null | head -20
/tmp/workspace
| Group | Papers |
|---|---|
| Pediatric GI / Constipation | Levy 2017, Rubin 2006 |
| Liver Surgery & Transplantation | Lladó 2004 (OLT techniques), Poon 2004 (hepatectomy for HCC), Poon 2007 (liver transection techniques), Regmi 2018 (liver transplant overview) |