[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75F3V5D7FRJ31WBAETN0JFC":3,"skill-same:01M75F3V5D7FRJ31WBAETN0JFC":49},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M75F3V5D7FRJ31WBAETN0JFC","habib-pdf-to-json",null,"Extract structured data from construction PDFs. Convert specifications, BOMs, schedules, and reports from PDF to Excel\u002FCSV\u002FJSON. Use OCR for scanned documents and pdfplumber for native PDFs.","javimosch\u002Fopen-claw-skills","javimosch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F12900508?v=4","01M6D3F2AS6PV75ET9PZ1QGP8J","Javier Leandro Arancibia","01M75B8NCTAJG9WH5YNZH7C3D8",0,"MIT","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdbmoradi60\u002Fhabib-pdf-to-json\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\r\nslug: \"pdf-to-structured\"\r\ndisplay_name: \"PDF To Structured\"\r\ndescription: \"Extract structured data from construction PDFs. Convert specifications, BOMs, schedules, and reports from PDF to Excel\u002FCSV\u002FJSON. Use OCR for scanned documents and pdfplumber for native PDFs.\"\r\n---\r\n\r\n# PDF to Structured Data Conversion\r\n\r\n## Overview\r\n\r\nBased on DDC methodology (Chapter 2.4), this skill transforms unstructured PDF documents into structured formats suitable for analysis and integration. Construction projects generate vast amounts of PDF documentation - specifications, BOMs, schedules, and reports - that need to be extracted and processed.\r\n\r\n**Book Reference:** \"Преобразование данных в структурированную форму\" \u002F \"Data Transformation to Structured Form\"\r\n\r\n> \"Преобразование данных из неструктурированной в структурированную форму — это и искусство, и наука. Этот процесс часто занимает значительную часть работы инженера по обработке данных.\"\r\n> — DDC Book, Chapter 2.4\r\n\r\n## ETL Process Overview\r\n\r\nThe conversion follows the ETL pattern:\r\n1. **Extract**: Load the PDF document\r\n2. **Transform**: Parse and structure the content\r\n3. **Load**: Save to CSV, Excel, or JSON\r\n\r\n## Quick Start\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\n\r\n# Extract table from PDF\r\nwith pdfplumber.open(\"construction_spec.pdf\") as pdf:\r\n    page = pdf.pages[0]\r\n    table = page.extract_table()\r\n    df = pd.DataFrame(table[1:], columns=table[0])\r\n    df.to_excel(\"extracted_data.xlsx\", index=False)\r\n```\r\n\r\n## Installation\r\n\r\n```bash\r\n# Core libraries\r\npip install pdfplumber pandas openpyxl\r\n\r\n# For scanned PDFs (OCR)\r\npip install pytesseract pdf2image\r\n# Also install Tesseract OCR: https:\u002F\u002Fgithub.com\u002Ftesseract-ocr\u002Ftesseract\r\n\r\n# For advanced PDF operations\r\npip install pypdf\r\n```\r\n\r\n## Native PDF Extraction (pdfplumber)\r\n\r\n### Extract All Tables from PDF\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\n\r\ndef extract_tables_from_pdf(pdf_path):\r\n    \"\"\"Extract all tables from a PDF file\"\"\"\r\n    all_tables = []\r\n\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        for page_num, page in enumerate(pdf.pages):\r\n            tables = page.extract_tables()\r\n            for table_num, table in enumerate(tables):\r\n                if table and len(table) > 1:\r\n                    # First row as header\r\n                    df = pd.DataFrame(table[1:], columns=table[0])\r\n                    df['_page'] = page_num + 1\r\n                    df['_table'] = table_num + 1\r\n                    all_tables.append(df)\r\n\r\n    if all_tables:\r\n        return pd.concat(all_tables, ignore_index=True)\r\n    return pd.DataFrame()\r\n\r\n# Usage\r\ndf = extract_tables_from_pdf(\"material_specification.pdf\")\r\ndf.to_excel(\"materials.xlsx\", index=False)\r\n```\r\n\r\n### Extract Text with Layout\r\n\r\n```python\r\nimport pdfplumber\r\n\r\ndef extract_text_with_layout(pdf_path):\r\n    \"\"\"Extract text preserving layout structure\"\"\"\r\n    full_text = []\r\n\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        for page in pdf.pages:\r\n            text = page.extract_text()\r\n            if text:\r\n                full_text.append(text)\r\n\r\n    return \"\\n\\n--- Page Break ---\\n\\n\".join(full_text)\r\n\r\n# Usage\r\ntext = extract_text_with_layout(\"project_report.pdf\")\r\nwith open(\"report_text.txt\", \"w\", encoding=\"utf-8\") as f:\r\n    f.write(text)\r\n```\r\n\r\n### Extract Specific Table by Position\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\n\r\ndef extract_table_from_area(pdf_path, page_num, bbox):\r\n    \"\"\"\r\n    Extract table from specific area on page\r\n\r\n    Args:\r\n        pdf_path: Path to PDF file\r\n        page_num: Page number (0-indexed)\r\n        bbox: Bounding box (x0, top, x1, bottom) in points\r\n    \"\"\"\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        page = pdf.pages[page_num]\r\n        cropped = page.within_bbox(bbox)\r\n        table = cropped.extract_table()\r\n\r\n        if table:\r\n            return pd.DataFrame(table[1:], columns=table[0])\r\n    return pd.DataFrame()\r\n\r\n# Usage - extract table from specific area\r\n# bbox format: (left, top, right, bottom) in points (1 inch = 72 points)\r\ndf = extract_table_from_area(\"drawing.pdf\", 0, (50, 100, 550, 400))\r\n```\r\n\r\n## Scanned PDF Processing (OCR)\r\n\r\n### Extract Text from Scanned PDF\r\n\r\n```python\r\nimport pytesseract\r\nfrom pdf2image import convert_from_path\r\nimport pandas as pd\r\n\r\ndef ocr_scanned_pdf(pdf_path, language='eng'):\r\n    \"\"\"\r\n    Extract text from scanned PDF using OCR\r\n\r\n    Args:\r\n        pdf_path: Path to scanned PDF\r\n        language: Tesseract language code (eng, deu, rus, etc.)\r\n    \"\"\"\r\n    # Convert PDF pages to images\r\n    images = convert_from_path(pdf_path, dpi=300)\r\n\r\n    extracted_text = []\r\n    for i, image in enumerate(images):\r\n        text = pytesseract.image_to_string(image, lang=language)\r\n        extracted_text.append({\r\n            'page': i + 1,\r\n            'text': text\r\n        })\r\n\r\n    return pd.DataFrame(extracted_text)\r\n\r\n# Usage\r\ndf = ocr_scanned_pdf(\"scanned_specification.pdf\", language='eng')\r\ndf.to_csv(\"ocr_results.csv\", index=False)\r\n```\r\n\r\n### OCR Table Extraction\r\n\r\n```python\r\nimport pytesseract\r\nfrom pdf2image import convert_from_path\r\nimport pandas as pd\r\nimport cv2\r\nimport numpy as np\r\n\r\ndef ocr_table_from_scanned_pdf(pdf_path, page_num=0):\r\n    \"\"\"Extract table from scanned PDF using OCR with table detection\"\"\"\r\n    # Convert specific page to image\r\n    images = convert_from_path(pdf_path, first_page=page_num+1,\r\n                                last_page=page_num+1, dpi=300)\r\n    image = np.array(images[0])\r\n\r\n    # Convert to grayscale\r\n    gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)\r\n\r\n    # Apply thresholding\r\n    _, binary = cv2.threshold(gray, 150, 255, cv2.THRESH_BINARY_INV)\r\n\r\n    # Extract text with table structure\r\n    custom_config = r'--oem 3 --psm 6'\r\n    text = pytesseract.image_to_string(gray, config=custom_config)\r\n\r\n    # Parse text into table structure\r\n    lines = text.strip().split('\\n')\r\n    data = [line.split() for line in lines if line.strip()]\r\n\r\n    if data:\r\n        # Assume first row is header\r\n        df = pd.DataFrame(data[1:], columns=data[0] if len(data[0]) > 0 else None)\r\n        return df\r\n    return pd.DataFrame()\r\n\r\n# Usage\r\ndf = ocr_table_from_scanned_pdf(\"scanned_bom.pdf\")\r\nprint(df)\r\n```\r\n\r\n## Construction-Specific Extractions\r\n\r\n### Bill of Materials (BOM) Extraction\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\nimport re\r\n\r\ndef extract_bom_from_pdf(pdf_path):\r\n    \"\"\"Extract Bill of Materials from construction PDF\"\"\"\r\n    all_items = []\r\n\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        for page in pdf.pages:\r\n            tables = page.extract_tables()\r\n            for table in tables:\r\n                if not table or len(table) \u003C 2:\r\n                    continue\r\n\r\n                # Find header row (look for common BOM headers)\r\n                header_keywords = ['item', 'description', 'quantity', 'unit', 'material']\r\n                for i, row in enumerate(table):\r\n                    if row and any(keyword in str(row).lower() for keyword in header_keywords):\r\n                        # Found header, process remaining rows\r\n                        headers = [str(h).strip() for h in row]\r\n                        for data_row in table[i+1:]:\r\n                            if data_row and any(cell for cell in data_row if cell):\r\n                                item = dict(zip(headers, data_row))\r\n                                all_items.append(item)\r\n                        break\r\n\r\n    return pd.DataFrame(all_items)\r\n\r\n# Usage\r\nbom = extract_bom_from_pdf(\"project_bom.pdf\")\r\nbom.to_excel(\"bom_extracted.xlsx\", index=False)\r\n```\r\n\r\n### Project Schedule Extraction\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\nfrom datetime import datetime\r\n\r\ndef extract_schedule_from_pdf(pdf_path):\r\n    \"\"\"Extract project schedule\u002Fgantt data from PDF\"\"\"\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        all_tasks = []\r\n\r\n        for page in pdf.pages:\r\n            tables = page.extract_tables()\r\n            for table in tables:\r\n                if not table:\r\n                    continue\r\n\r\n                # Look for schedule-like table\r\n                headers = table[0] if table else []\r\n\r\n                # Check if it looks like a schedule\r\n                schedule_keywords = ['task', 'activity', 'start', 'end', 'duration']\r\n                if any(kw in str(headers).lower() for kw in schedule_keywords):\r\n                    for row in table[1:]:\r\n                        if row and any(cell for cell in row if cell):\r\n                            task = dict(zip(headers, row))\r\n                            all_tasks.append(task)\r\n\r\n    df = pd.DataFrame(all_tasks)\r\n\r\n    # Try to parse dates\r\n    date_columns = ['Start', 'End', 'Start Date', 'End Date', 'Finish']\r\n    for col in date_columns:\r\n        if col in df.columns:\r\n            df[col] = pd.to_datetime(df[col], errors='coerce')\r\n\r\n    return df\r\n\r\n# Usage\r\nschedule = extract_schedule_from_pdf(\"project_schedule.pdf\")\r\nprint(schedule)\r\n```\r\n\r\n### Specification Parsing\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\nimport re\r\n\r\ndef parse_specification_pdf(pdf_path):\r\n    \"\"\"Parse construction specification document\"\"\"\r\n    specs = []\r\n\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        full_text = \"\"\r\n        for page in pdf.pages:\r\n            text = page.extract_text()\r\n            if text:\r\n                full_text += text + \"\\n\"\r\n\r\n    # Parse sections (common spec format)\r\n    section_pattern = r'(\\d+\\.\\d+(?:\\.\\d+)?)\\s+([A-Z][^\\n]+)'\r\n    sections = re.findall(section_pattern, full_text)\r\n\r\n    for num, title in sections:\r\n        specs.append({\r\n            'section_number': num,\r\n            'title': title.strip(),\r\n            'level': len(num.split('.'))\r\n        })\r\n\r\n    return pd.DataFrame(specs)\r\n\r\n# Usage\r\nspecs = parse_specification_pdf(\"technical_spec.pdf\")\r\nprint(specs)\r\n```\r\n\r\n## Batch Processing\r\n\r\n### Process Multiple PDFs\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\nfrom pathlib import Path\r\n\r\ndef batch_extract_tables(folder_path, output_folder):\r\n    \"\"\"Process all PDFs in folder and extract tables\"\"\"\r\n    pdf_files = Path(folder_path).glob(\"*.pdf\")\r\n    results = []\r\n\r\n    for pdf_path in pdf_files:\r\n        print(f\"Processing: {pdf_path.name}\")\r\n        try:\r\n            with pdfplumber.open(pdf_path) as pdf:\r\n                for page_num, page in enumerate(pdf.pages):\r\n                    tables = page.extract_tables()\r\n                    for table_num, table in enumerate(tables):\r\n                        if table and len(table) > 1:\r\n                            df = pd.DataFrame(table[1:], columns=table[0])\r\n                            df['_source_file'] = pdf_path.name\r\n                            df['_page'] = page_num + 1\r\n\r\n                            # Save individual table\r\n                            output_name = f\"{pdf_path.stem}_p{page_num+1}_t{table_num+1}.xlsx\"\r\n                            df.to_excel(Path(output_folder) \u002F output_name, index=False)\r\n                            results.append(df)\r\n        except Exception as e:\r\n            print(f\"Error processing {pdf_path.name}: {e}\")\r\n\r\n    # Combined output\r\n    if results:\r\n        combined = pd.concat(results, ignore_index=True)\r\n        combined.to_excel(Path(output_folder) \u002F \"all_tables.xlsx\", index=False)\r\n\r\n    return len(results)\r\n\r\n# Usage\r\ncount = batch_extract_tables(\".\u002Fpdf_documents\u002F\", \".\u002Fextracted\u002F\")\r\nprint(f\"Extracted {count} tables\")\r\n```\r\n\r\n## Data Cleaning After Extraction\r\n\r\n```python\r\nimport pandas as pd\r\n\r\ndef clean_extracted_data(df):\r\n    \"\"\"Clean common issues in PDF-extracted data\"\"\"\r\n    # Remove completely empty rows\r\n    df = df.dropna(how='all')\r\n\r\n    # Strip whitespace from string columns\r\n    for col in df.select_dtypes(include=['object']).columns:\r\n        df[col] = df[col].str.strip()\r\n\r\n    # Remove rows where all cells are empty strings\r\n    df = df[df.apply(lambda row: any(cell != '' for cell in row), axis=1)]\r\n\r\n    # Convert numeric columns\r\n    for col in df.columns:\r\n        # Try to convert to numeric\r\n        numeric_series = pd.to_numeric(df[col], errors='coerce')\r\n        if numeric_series.notna().sum() > len(df) * 0.5:  # More than 50% numeric\r\n            df[col] = numeric_series\r\n\r\n    return df\r\n\r\n# Usage\r\ndf = extract_tables_from_pdf(\"document.pdf\")\r\ndf_clean = clean_extracted_data(df)\r\ndf_clean.to_excel(\"clean_data.xlsx\", index=False)\r\n```\r\n\r\n## Export Options\r\n\r\n```python\r\nimport pandas as pd\r\nimport json\r\n\r\ndef export_to_multiple_formats(df, base_name):\r\n    \"\"\"Export DataFrame to multiple formats\"\"\"\r\n    # Excel\r\n    df.to_excel(f\"{base_name}.xlsx\", index=False)\r\n\r\n    # CSV\r\n    df.to_csv(f\"{base_name}.csv\", index=False, encoding='utf-8-sig')\r\n\r\n    # JSON\r\n    df.to_json(f\"{base_name}.json\", orient='records', indent=2)\r\n\r\n    # JSON Lines (for large datasets)\r\n    df.to_json(f\"{base_name}.jsonl\", orient='records', lines=True)\r\n\r\n# Usage\r\ndf = extract_tables_from_pdf(\"document.pdf\")\r\nexport_to_multiple_formats(df, \"extracted_data\")\r\n```\r\n\r\n## Quick Reference\r\n\r\n| Task | Tool | Code |\r\n|------|------|------|\r\n| Extract table | pdfplumber | `page.extract_table()` |\r\n| Extract text | pdfplumber | `page.extract_text()` |\r\n| OCR scanned | pytesseract | `pytesseract.image_to_string(image)` |\r\n| Merge PDFs | pypdf | `writer.add_page(page)` |\r\n| Convert to image | pdf2image | `convert_from_path(pdf)` |\r\n\r\n## Troubleshooting\r\n\r\n| Issue | Solution |\r\n|-------|----------|\r\n| Table not detected | Try adjusting table settings: `page.extract_table(table_settings={})` |\r\n| Wrong column alignment | Use visual debugging: `page.to_image().draw_rects()` |\r\n| OCR quality poor | Increase DPI, preprocess image, use correct language |\r\n| Memory issues | Process pages one at a time, close PDF after processing |\r\n\r\n## Resources\r\n\r\n- **Book**: \"Data-Driven Construction\" by Artem Boiko, Chapter 2.4\r\n- **Website**: https:\u002F\u002Fdatadrivenconstruction.io\r\n- **pdfplumber Docs**: https:\u002F\u002Fgithub.com\u002Fjsvine\u002Fpdfplumber\r\n- **Tesseract OCR**: https:\u002F\u002Fgithub.com\u002Ftesseract-ocr\u002Ftesseract\r\n\r\n## Next Steps\r\n\r\n- See `image-to-data` for image processing\r\n- See `cad-to-data` for CAD\u002FBIM data extraction\r\n- See `etl-pipeline` for automated processing workflows\r\n- See `data-quality-check` for validating extracted data\r\n","# PDF to Structured Data Conversion\r\n\r\n## Overview\r\n\r\nBased on DDC methodology (Chapter 2.4), this skill transforms unstructured PDF documents into structured formats suitable for analysis and integration. Construction projects generate vast amounts of PDF documentation - specifications, BOMs, schedules, and reports - that need to be extracted and processed.\r\n\r\n**Book Reference:** \"Преобразование данных в структурированную форму\" \u002F \"Data Transformation to Structured Form\"\r\n\r\n> \"Преобразование данных из неструктурированной в структурированную форму — это и искусство, и наука. Этот процесс часто занимает значительную часть работы инженера по обработке данных.\"\r\n> — DDC Book, Chapter 2.4\r\n\r\n## ETL Process Overview\r\n\r\nThe conversion follows the ETL pattern:\r\n1. **Extract**: Load the PDF document\r\n2. **Transform**: Parse and structure the content\r\n3. **Load**: Save to CSV, Excel, or JSON\r\n\r\n## Quick Start\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\n\r\n# Extract table from PDF\r\nwith pdfplumber.open(\"construction_spec.pdf\") as pdf:\r\n    page = pdf.pages[0]\r\n    table = page.extract_table()\r\n    df = pd.DataFrame(table[1:], columns=table[0])\r\n    df.to_excel(\"extracted_data.xlsx\", index=False)\r\n```\r\n\r\n## Installation\r\n\r\n```bash\r\n# Core libraries\r\npip install pdfplumber pandas openpyxl\r\n\r\n# For scanned PDFs (OCR)\r\npip install pytesseract pdf2image\r\n# Also install Tesseract OCR: https:\u002F\u002Fgithub.com\u002Ftesseract-ocr\u002Ftesseract\r\n\r\n# For advanced PDF operations\r\npip install pypdf\r\n```\r\n\r\n## Native PDF Extraction (pdfplumber)\r\n\r\n### Extract All Tables from PDF\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\n\r\ndef extract_tables_from_pdf(pdf_path):\r\n    \"\"\"Extract all tables from a PDF file\"\"\"\r\n    all_tables = []\r\n\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        for page_num, page in enumerate(pdf.pages):\r\n            tables = page.extract_tables()\r\n            for table_num, table in enumerate(tables):\r\n                if table and len(table) > 1:\r\n                    # First row as header\r\n                    df = pd.DataFrame(table[1:], columns=table[0])\r\n                    df['_page'] = page_num + 1\r\n                    df['_table'] = table_num + 1\r\n                    all_tables.append(df)\r\n\r\n    if all_tables:\r\n        return pd.concat(all_tables, ignore_index=True)\r\n    return pd.DataFrame()\r\n\r\n# Usage\r\ndf = extract_tables_from_pdf(\"material_specification.pdf\")\r\ndf.to_excel(\"materials.xlsx\", index=False)\r\n```\r\n\r\n### Extract Text with Layout\r\n\r\n```python\r\nimport pdfplumber\r\n\r\ndef extract_text_with_layout(pdf_path):\r\n    \"\"\"Extract text preserving layout structure\"\"\"\r\n    full_text = []\r\n\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        for page in pdf.pages:\r\n            text = page.extract_text()\r\n            if text:\r\n                full_text.append(text)\r\n\r\n    return \"\\n\\n--- Page Break ---\\n\\n\".join(full_text)\r\n\r\n# Usage\r\ntext = extract_text_with_layout(\"project_report.pdf\")\r\nwith open(\"report_text.txt\", \"w\", encoding=\"utf-8\") as f:\r\n    f.write(text)\r\n```\r\n\r\n### Extract Specific Table by Position\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\n\r\ndef extract_table_from_area(pdf_path, page_num, bbox):\r\n    \"\"\"\r\n    Extract table from specific area on page\r\n\r\n    Args:\r\n        pdf_path: Path to PDF file\r\n        page_num: Page number (0-indexed)\r\n        bbox: Bounding box (x0, top, x1, bottom) in points\r\n    \"\"\"\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        page = pdf.pages[page_num]\r\n        cropped = page.within_bbox(bbox)\r\n        table = cropped.extract_table()\r\n\r\n        if table:\r\n            return pd.DataFrame(table[1:], columns=table[0])\r\n    return pd.DataFrame()\r\n\r\n# Usage - extract table from specific area\r\n# bbox format: (left, top, right, bottom) in points (1 inch = 72 points)\r\ndf = extract_table_from_area(\"drawing.pdf\", 0, (50, 100, 550, 400))\r\n```\r\n\r\n## Scanned PDF Processing (OCR)\r\n\r\n### Extract Text from Scanned PDF\r\n\r\n```python\r\nimport pytesseract\r\nfrom pdf2image import convert_from_path\r\nimport pandas as pd\r\n\r\ndef ocr_scanned_pdf(pdf_path, language='eng'):\r\n    \"\"\"\r\n    Extract text from scanned PDF using OCR\r\n\r\n    Args:\r\n        pdf_path: Path to scanned PDF\r\n        language: Tesseract language code (eng, deu, rus, etc.)\r\n    \"\"\"\r\n    # Convert PDF pages to images\r\n    images = convert_from_path(pdf_path, dpi=300)\r\n\r\n    extracted_text = []\r\n    for i, image in enumerate(images):\r\n        text = pytesseract.image_to_string(image, lang=language)\r\n        extracted_text.append({\r\n            'page': i + 1,\r\n            'text': text\r\n        })\r\n\r\n    return pd.DataFrame(extracted_text)\r\n\r\n# Usage\r\ndf = ocr_scanned_pdf(\"scanned_specification.pdf\", language='eng')\r\ndf.to_csv(\"ocr_results.csv\", index=False)\r\n```\r\n\r\n### OCR Table Extraction\r\n\r\n```python\r\nimport pytesseract\r\nfrom pdf2image import convert_from_path\r\nimport pandas as pd\r\nimport cv2\r\nimport numpy as np\r\n\r\ndef ocr_table_from_scanned_pdf(pdf_path, page_num=0):\r\n    \"\"\"Extract table from scanned PDF using OCR with table detection\"\"\"\r\n    # Convert specific page to image\r\n    images = convert_from_path(pdf_path, first_page=page_num+1,\r\n                                last_page=page_num+1, dpi=300)\r\n    image = np.array(images[0])\r\n\r\n    # Convert to grayscale\r\n    gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)\r\n\r\n    # Apply thresholding\r\n    _, binary = cv2.threshold(gray, 150, 255, cv2.THRESH_BINARY_INV)\r\n\r\n    # Extract text with table structure\r\n    custom_config = r'--oem 3 --psm 6'\r\n    text = pytesseract.image_to_string(gray, config=custom_config)\r\n\r\n    # Parse text into table structure\r\n    lines = text.strip().split('\\n')\r\n    data = [line.split() for line in lines if line.strip()]\r\n\r\n    if data:\r\n        # Assume first row is header\r\n        df = pd.DataFrame(data[1:], columns=data[0] if len(data[0]) > 0 else None)\r\n        return df\r\n    return pd.DataFrame()\r\n\r\n# Usage\r\ndf = ocr_table_from_scanned_pdf(\"scanned_bom.pdf\")\r\nprint(df)\r\n```\r\n\r\n## Construction-Specific Extractions\r\n\r\n### Bill of Materials (BOM) Extraction\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\nimport re\r\n\r\ndef extract_bom_from_pdf(pdf_path):\r\n    \"\"\"Extract Bill of Materials from construction PDF\"\"\"\r\n    all_items = []\r\n\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        for page in pdf.pages:\r\n            tables = page.extract_tables()\r\n            for table in tables:\r\n                if not table or len(table) \u003C 2:\r\n                    continue\r\n\r\n                # Find header row (look for common BOM headers)\r\n                header_keywords = ['item', 'description', 'quantity', 'unit', 'material']\r\n                for i, row in enumerate(table):\r\n                    if row and any(keyword in str(row).lower() for keyword in header_keywords):\r\n                        # Found header, process remaining rows\r\n                        headers = [str(h).strip() for h in row]\r\n                        for data_row in table[i+1:]:\r\n                            if data_row and any(cell for cell in data_row if cell):\r\n                                item = dict(zip(headers, data_row))\r\n                                all_items.append(item)\r\n                        break\r\n\r\n    return pd.DataFrame(all_items)\r\n\r\n# Usage\r\nbom = extract_bom_from_pdf(\"project_bom.pdf\")\r\nbom.to_excel(\"bom_extracted.xlsx\", index=False)\r\n```\r\n\r\n### Project Schedule Extraction\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\nfrom datetime import datetime\r\n\r\ndef extract_schedule_from_pdf(pdf_path):\r\n    \"\"\"Extract project schedule\u002Fgantt data from PDF\"\"\"\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        all_tasks = []\r\n\r\n        for page in pdf.pages:\r\n            tables = page.extract_tables()\r\n            for table in tables:\r\n                if not table:\r\n                    continue\r\n\r\n                # Look for schedule-like table\r\n                headers = table[0] if table else []\r\n\r\n                # Check if it looks like a schedule\r\n                schedule_keywords = ['task', 'activity', 'start', 'end', 'duration']\r\n                if any(kw in str(headers).lower() for kw in schedule_keywords):\r\n                    for row in table[1:]:\r\n                        if row and any(cell for cell in row if cell):\r\n                            task = dict(zip(headers, row))\r\n                            all_tasks.append(task)\r\n\r\n    df = pd.DataFrame(all_tasks)\r\n\r\n    # Try to parse dates\r\n    date_columns = ['Start', 'End', 'Start Date', 'End Date', 'Finish']\r\n    for col in date_columns:\r\n        if col in df.columns:\r\n            df[col] = pd.to_datetime(df[col], errors='coerce')\r\n\r\n    return df\r\n\r\n# Usage\r\nschedule = extract_schedule_from_pdf(\"project_schedule.pdf\")\r\nprint(schedule)\r\n```\r\n\r\n### Specification Parsing\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\nimport re\r\n\r\ndef parse_specification_pdf(pdf_path):\r\n    \"\"\"Parse construction specification document\"\"\"\r\n    specs = []\r\n\r\n    with pdfplumber.open(pdf_path) as pdf:\r\n        full_text = \"\"\r\n        for page in pdf.pages:\r\n            text = page.extract_text()\r\n            if text:\r\n                full_text += text + \"\\n\"\r\n\r\n    # Parse sections (common spec format)\r\n    section_pattern = r'(\\d+\\.\\d+(?:\\.\\d+)?)\\s+([A-Z][^\\n]+)'\r\n    sections = re.findall(section_pattern, full_text)\r\n\r\n    for num, title in sections:\r\n        specs.append({\r\n            'section_number': num,\r\n            'title': title.strip(),\r\n            'level': len(num.split('.'))\r\n        })\r\n\r\n    return pd.DataFrame(specs)\r\n\r\n# Usage\r\nspecs = parse_specification_pdf(\"technical_spec.pdf\")\r\nprint(specs)\r\n```\r\n\r\n## Batch Processing\r\n\r\n### Process Multiple PDFs\r\n\r\n```python\r\nimport pdfplumber\r\nimport pandas as pd\r\nfrom pathlib import Path\r\n\r\ndef batch_extract_tables(folder_path, output_folder):\r\n    \"\"\"Process all PDFs in folder and extract tables\"\"\"\r\n    pdf_files = Path(folder_path).glob(\"*.pdf\")\r\n    results = []\r\n\r\n    for pdf_path in pdf_files:\r\n        print(f\"Processing: {pdf_path.name}\")\r\n        try:\r\n            with pdfplumber.open(pdf_path) as pdf:\r\n                for page_num, page in enumerate(pdf.pages):\r\n                    tables = page.extract_tables()\r\n                    for table_num, table in enumerate(tables):\r\n                        if table and len(table) > 1:\r\n                            df = pd.DataFrame(table[1:], columns=table[0])\r\n                            df['_source_file'] = pdf_path.name\r\n                            df['_page'] = page_num + 1\r\n\r\n                            # Save individual table\r\n                            output_name = f\"{pdf_path.stem}_p{page_num+1}_t{table_num+1}.xlsx\"\r\n                            df.to_excel(Path(output_folder) \u002F output_name, index=False)\r\n                            results.append(df)\r\n        except Exception as e:\r\n            print(f\"Error processing {pdf_path.name}: {e}\")\r\n\r\n    # Combined output\r\n    if results:\r\n        combined = pd.concat(results, ignore_index=True)\r\n        combined.to_excel(Path(output_folder) \u002F \"all_tables.xlsx\", index=False)\r\n\r\n    return len(results)\r\n\r\n# Usage\r\ncount = batch_extract_tables(\".\u002Fpdf_documents\u002F\", \".\u002Fextracted\u002F\")\r\nprint(f\"Extracted {count} tables\")\r\n```\r\n\r\n## Data Cleaning After Extraction\r\n\r\n```python\r\nimport pandas as pd\r\n\r\ndef clean_extracted_data(df):\r\n    \"\"\"Clean common issues in PDF-extracted data\"\"\"\r\n    # Remove completely empty rows\r\n    df = df.dropna(how='all')\r\n\r\n    # Strip whitespace from string columns\r\n    for col in df.select_dtypes(include=['object']).columns:\r\n        df[col] = df[col].str.strip()\r\n\r\n    # Remove rows where all cells are empty strings\r\n    df = df[df.apply(lambda row: any(cell != '' for cell in row), axis=1)]\r\n\r\n    # Convert numeric columns\r\n    for col in df.columns:\r\n        # Try to convert to numeric\r\n        numeric_series = pd.to_numeric(df[col], errors='coerce')\r\n        if numeric_series.notna().sum() > len(df) * 0.5:  # More than 50% numeric\r\n            df[col] = numeric_series\r\n\r\n    return df\r\n\r\n# Usage\r\ndf = extract_tables_from_pdf(\"document.pdf\")\r\ndf_clean = clean_extracted_data(df)\r\ndf_clean.to_excel(\"clean_data.xlsx\", index=False)\r\n```\r\n\r\n## Export Options\r\n\r\n```python\r\nimport pandas as pd\r\nimport json\r\n\r\ndef export_to_multiple_formats(df, base_name):\r\n    \"\"\"Export DataFrame to multiple formats\"\"\"\r\n    # Excel\r\n    df.to_excel(f\"{base_name}.xlsx\", index=False)\r\n\r\n    # CSV\r\n    df.to_csv(f\"{base_name}.csv\", index=False, encoding='utf-8-sig')\r\n\r\n    # JSON\r\n    df.to_json(f\"{base_name}.json\", orient='records', indent=2)\r\n\r\n    # JSON Lines (for large datasets)\r\n    df.to_json(f\"{base_name}.jsonl\", orient='records', lines=True)\r\n\r\n# Usage\r\ndf = extract_tables_from_pdf(\"document.pdf\")\r\nexport_to_multiple_formats(df, \"extracted_data\")\r\n```\r\n\r\n## Quick Reference\r\n\r\n| Task | Tool | Code |\r\n|------|------|------|\r\n| Extract table | pdfplumber | `page.extract_table()` |\r\n| Extract text | pdfplumber | `page.extract_text()` |\r\n| OCR scanned | pytesseract | `pytesseract.image_to_string(image)` |\r\n| Merge PDFs | pypdf | `writer.add_page(page)` |\r\n| Convert to image | pdf2image | `convert_from_path(pdf)` |\r\n\r\n## Troubleshooting\r\n\r\n| Issue | Solution |\r\n|-------|----------|\r\n| Table not detected | Try adjusting table settings: `page.extract_table(table_settings={})` |\r\n| Wrong column alignment | Use visual debugging: `page.to_image().draw_rects()` |\r\n| OCR quality poor | Increase DPI, preprocess image, use correct language |\r\n| Memory issues | Process pages one at a time, close PDF after processing |\r\n\r\n## Resources\r\n\r\n- **Book**: \"Data-Driven Construction\" by Artem Boiko, Chapter 2.4\r\n- **Website**: https:\u002F\u002Fdatadrivenconstruction.io\r\n- **pdfplumber Docs**: https:\u002F\u002Fgithub.com\u002Fjsvine\u002Fpdfplumber\r\n- **Tesseract OCR**: https:\u002F\u002Fgithub.com\u002Ftesseract-ocr\u002Ftesseract\r\n\r\n## Next Steps\r\n\r\n- See `image-to-data` for image processing\r\n- See `cad-to-data` for CAD\u002FBIM data extraction\r\n- See `etl-pipeline` for automated processing workflows\r\n- See `data-quality-check` for validating extracted data\r\n",{"slug":24,"description":7,"display_name":25},"pdf-to-structured","PDF To Structured","main","f9d3fe7cf9ac8f1ea63a0d96e98e1f510a3814db","skills\u002Fdbmoradi60\u002Fhabib-pdf-to-json",1,"https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills","https:\u002F\u002Fgithub.com\u002Fjavimosch","intrane.fr","Building robust, open-source infrastructure for the commons. AI-leveraged, self-hosted, built to last.","2026-06-07 03:34:58",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add javimosch\u002Fopen-claw-skills --skill habib-pdf-to-json",{"tool":41,"command":42},"bunx","bunx skills add javimosch\u002Fopen-claw-skills --skill habib-pdf-to-json",{"tool":44,"command":45},"pnpm","pnpm dlx skills add javimosch\u002Fopen-claw-skills --skill habib-pdf-to-json","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdbmoradi60\u002Fhabib-pdf-to-json\u002FSKILL.md",true,[],[50,58,65,72,79,86],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":57},"01M778GGXG2VQ0YF31W2MKGMQZ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":57},"01M778G7BH8SBJ9FJ6C3G7CB1K","ceaser","Interact with the Ceaser privacy protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- shield, unshield, note management, and protocol queries. All ceaser tool calls use CLI subcommands (npx -y ceaser-mcp \u003Csubcommand>). Ceaser is a privacy-preserving ETH wrapper using Noir\u002FUltraHonk zero-knowledge proofs on Base L2 (chain ID 8453).","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyra-v21\u002Fceaser\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":57},"01M778FYCJQZWFKKX5FYMK3S47","ceaser-send","Fully automated private ETH transfer via Ceaser Protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- all ceaser tool calls use CLI subcommands (npx -y ceaser-mcp \u003Csubcommand>). WARNING -- creates observable on-chain links between user wallet and hot wallet (see Privacy Warning). Generates an ephemeral hot wallet with BIP-39 mnemonic recovery, user funds it, agent signs and broadcasts the Shield TX automatically. Exactly one manual step required (funding the hot wallet with ETH). Uses Noir\u002FUltraHonk zero-knowledge proofs.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyra-v21\u002Fceaser-send\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":57},"01M778FQQNSEYA3HJKZBPQ4M9Z","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":57},"01M778FGVZX7QA2TF9BFMM37FY","moldium","Post and manage content on the Moldium blog platform. Triggered by \"post to Moldium\", \"write a blog post\", \"publish an article\", etc.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyom45\u002Fmoldium\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":57},"01M778F88D8PQ9MQ0KNW2TJ8ZH","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, submit comments, search papers, and import papers. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, submitting paper reviews, searching papers by title, or importing papers from arXiv URLs via API at http:\u002F\u002Fweakaccept.top:8000\u002F.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[],[]]