[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KGTMTJR6RXXC8AF29MQQW5":3,"skill-same:01M6KGTMTJR6RXXC8AF29MQQW5":82},{"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":35,"linkOnly":36,"markdownContent":37,"markdownBody":38,"frontMatter":39,"refName":61,"commitSha":62,"skillDirectory":63,"forksCount":64,"repositoryHtmlUrl":65,"repositoryHomepageUrl":6,"ownerHtmlUrl":66,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":67,"install":68,"resources":81},"01M6KGTMTJR6RXXC8AF29MQQW5","table-extractor",null,">","legout\u002Fpi-config","legout","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1469563?v=4","01M6KGERP7E8TF4XARRKPFJ6HQ","Volker L.","01M6KGERT1FYD049PP1WW923TZ",3,"MIT","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Ftable-extractor\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"table","table extractor","PDF","MCP","gpt","extraction","office","data","parsing","extract","en","zh","camelot","sonnet","opus","tables","2026-11-10 10:12:30",false,"---\n# ═══════════════════════════════════════════════════════════════════════════════\n# CLAUDE OFFICE SKILL - Enhanced Metadata v2.0\n# ═══════════════════════════════════════════════════════════════════════════════\n\n# Basic Information\nname: table-extractor\ndescription: \">\"\nversion: \"1.0\"\nauthor: claude-office-skills\nlicense: MIT\n\n# Categorization\ncategory: parsing\ntags:\n  - table\n  - extraction\n  - pdf\n  - camelot\ndepartment: All\n\n# AI Model Compatibility\nmodels:\n  recommended:\n    - claude-sonnet-4\n    - claude-opus-4\n  compatible:\n    - claude-3-5-sonnet\n    - gpt-4\n    - gpt-4o\n\n# MCP Tools Integration\nmcp:\n  server: office-mcp\n  tools:\n    - extract_tables_from_pdf\n\n# Skill Capabilities\ncapabilities:\n  - table_extraction\n  - data_structuring\n\n# Language Support\nlanguages:\n  - en\n  - zh\n---\n\n# Table Extractor Skill\n\n## Overview\n\nThis skill enables precise extraction of tables from PDF documents using **camelot** - the gold standard for PDF table extraction. Handle complex tables with merged cells, borderless tables, and multi-page layouts with high accuracy.\n\n## How to Use\n\n1. Provide the PDF containing tables\n2. Optionally specify pages or table detection method\n3. I'll extract tables as pandas DataFrames\n\n**Example prompts:**\n- \"Extract all tables from this PDF\"\n- \"Get the table on page 5 of this report\"\n- \"Extract borderless tables from this document\"\n- \"Convert PDF tables to Excel format\"\n\n## Domain Knowledge\n\n### camelot Fundamentals\n\n```python\nimport camelot\n\n# Extract tables from PDF\ntables = camelot.read_pdf('document.pdf')\n\n# Access results\nprint(f\"Found {len(tables)} tables\")\n\n# Get first table as DataFrame\ndf = tables[0].df\nprint(df)\n```\n\n### Extraction Methods\n\n| Method | Use Case | Description |\n|--------|----------|-------------|\n| `lattice` | Bordered tables | Detects table by lines\u002Fborders |\n| `stream` | Borderless tables | Uses text positioning |\n\n```python\n# Lattice method (default) - for tables with visible borders\ntables = camelot.read_pdf('document.pdf', flavor='lattice')\n\n# Stream method - for borderless tables\ntables = camelot.read_pdf('document.pdf', flavor='stream')\n```\n\n### Page Selection\n\n```python\n# Single page\ntables = camelot.read_pdf('document.pdf', pages='1')\n\n# Multiple pages\ntables = camelot.read_pdf('document.pdf', pages='1,3,5')\n\n# Page range\ntables = camelot.read_pdf('document.pdf', pages='1-5')\n\n# All pages\ntables = camelot.read_pdf('document.pdf', pages='all')\n```\n\n### Advanced Options\n\n#### Lattice Options\n```python\ntables = camelot.read_pdf(\n    'document.pdf',\n    flavor='lattice',\n    line_scale=40,              # Line detection sensitivity\n    copy_text=['h', 'v'],       # Copy text across merged cells\n    shift_text=['l', 't'],      # Shift text alignment\n    split_text=True,            # Split text at newlines\n    flag_size=True,             # Flag super\u002Fsubscripts\n    strip_text='\\n',            # Characters to strip\n    process_background=False,   # Process background lines\n)\n```\n\n#### Stream Options\n```python\ntables = camelot.read_pdf(\n    'document.pdf',\n    flavor='stream',\n    edge_tol=500,               # Edge tolerance\n    row_tol=10,                 # Row tolerance\n    column_tol=0,               # Column tolerance\n    strip_text='\\n',            # Characters to strip\n)\n```\n\n### Table Area Specification\n\n```python\n# Extract from specific area (x1, y1, x2, y2)\n# Coordinates from bottom-left, in PDF points (72 points = 1 inch)\ntables = camelot.read_pdf(\n    'document.pdf',\n    table_areas=['72,720,540,400'],  # One area\n)\n\n# Multiple areas\ntables = camelot.read_pdf(\n    'document.pdf',\n    table_areas=['72,720,540,400', '72,380,540,200'],\n)\n```\n\n### Column Specification\n\n```python\n# Manually specify column positions (for stream method)\ntables = camelot.read_pdf(\n    'document.pdf',\n    flavor='stream',\n    columns=['100,200,300,400'],  # X positions of column separators\n)\n```\n\n### Working with Results\n\n```python\nimport camelot\n\ntables = camelot.read_pdf('document.pdf')\n\nfor i, table in enumerate(tables):\n    # Access DataFrame\n    df = table.df\n    \n    # Table metadata\n    print(f\"Table {i+1}:\")\n    print(f\"  Page: {table.page}\")\n    print(f\"  Accuracy: {table.accuracy}\")\n    print(f\"  Whitespace: {table.whitespace}\")\n    print(f\"  Order: {table.order}\")\n    print(f\"  Shape: {df.shape}\")\n    \n    # Parsing report\n    report = table.parsing_report\n    print(f\"  Report: {report}\")\n```\n\n### Export Options\n\n```python\nimport camelot\n\ntables = camelot.read_pdf('document.pdf')\n\n# Export to CSV\ntables[0].to_csv('table.csv')\n\n# Export to Excel\ntables[0].to_excel('table.xlsx')\n\n# Export to JSON\ntables[0].to_json('table.json')\n\n# Export to HTML\ntables[0].to_html('table.html')\n\n# Export all tables\nfor i, table in enumerate(tables):\n    table.to_excel(f'table_{i+1}.xlsx')\n```\n\n### Visual Debugging\n\n```python\nimport camelot\n\n# Enable visual debugging\ntables = camelot.read_pdf('document.pdf')\n\n# Plot detected table areas\ncamelot.plot(tables[0], kind='contour').show()\n\n# Plot text on table\ncamelot.plot(tables[0], kind='text').show()\n\n# Plot detected lines (lattice only)\ncamelot.plot(tables[0], kind='joint').show()\ncamelot.plot(tables[0], kind='line').show()\n\n# Save plot\nfig = camelot.plot(tables[0])\nfig.savefig('debug.png')\n```\n\n### Handling Multi-page Tables\n\n```python\nimport camelot\nimport pandas as pd\n\ndef extract_multipage_table(pdf_path, pages='all'):\n    \"\"\"Extract and combine tables that span multiple pages.\"\"\"\n    \n    tables = camelot.read_pdf(pdf_path, pages=pages)\n    \n    # Group tables by similar structure (columns)\n    table_groups = {}\n    \n    for table in tables:\n        cols = tuple(table.df.columns)\n        if cols not in table_groups:\n            table_groups[cols] = []\n        table_groups[cols].append(table.df)\n    \n    # Combine similar tables\n    combined = []\n    for cols, dfs in table_groups.items():\n        if len(dfs) > 1:\n            # Combine and deduplicate header rows\n            combined_df = pd.concat(dfs, ignore_index=True)\n            combined.append(combined_df)\n        else:\n            combined.append(dfs[0])\n    \n    return combined\n```\n\n## Best Practices\n\n1. **Try Both Methods**: Lattice for bordered, stream for borderless\n2. **Check Accuracy Score**: Above 90% is usually good\n3. **Use Visual Debugging**: Understand extraction results\n4. **Specify Areas**: For PDFs with multiple table types\n5. **Handle Headers**: First row often needs special treatment\n\n## Common Patterns\n\n### Batch Table Extraction\n```python\nimport camelot\nfrom pathlib import Path\nimport pandas as pd\n\ndef batch_extract_tables(input_dir, output_dir):\n    \"\"\"Extract tables from all PDFs in directory.\"\"\"\n    \n    input_path = Path(input_dir)\n    output_path = Path(output_dir)\n    output_path.mkdir(exist_ok=True)\n    \n    results = []\n    \n    for pdf_file in input_path.glob('*.pdf'):\n        try:\n            tables = camelot.read_pdf(str(pdf_file), pages='all')\n            \n            for i, table in enumerate(tables):\n                # Skip low accuracy tables\n                if table.accuracy \u003C 80:\n                    continue\n                \n                output_file = output_path \u002F f\"{pdf_file.stem}_table_{i+1}.xlsx\"\n                table.to_excel(str(output_file))\n                \n                results.append({\n                    'source': str(pdf_file),\n                    'table': i + 1,\n                    'page': table.page,\n                    'accuracy': table.accuracy,\n                    'output': str(output_file)\n                })\n        \n        except Exception as e:\n            results.append({\n                'source': str(pdf_file),\n                'error': str(e)\n            })\n    \n    return results\n```\n\n### Auto-detect Table Method\n```python\nimport camelot\n\ndef smart_extract_tables(pdf_path, pages='1'):\n    \"\"\"Try both methods and return best results.\"\"\"\n    \n    # Try lattice first\n    lattice_tables = camelot.read_pdf(pdf_path, pages=pages, flavor='lattice')\n    \n    # Try stream\n    stream_tables = camelot.read_pdf(pdf_path, pages=pages, flavor='stream')\n    \n    # Compare and return best\n    results = []\n    \n    if lattice_tables and lattice_tables[0].accuracy > 70:\n        results.extend(lattice_tables)\n    elif stream_tables:\n        results.extend(stream_tables)\n    \n    return results\n```\n\n## Examples\n\n### Example 1: Financial Statement Extraction\n```python\nimport camelot\nimport pandas as pd\n\ndef extract_financial_tables(pdf_path):\n    \"\"\"Extract financial tables from annual report.\"\"\"\n    \n    # Extract all tables\n    tables = camelot.read_pdf(pdf_path, pages='all', flavor='lattice')\n    \n    financial_data = {\n        'income_statement': None,\n        'balance_sheet': None,\n        'cash_flow': None,\n        'other_tables': []\n    }\n    \n    for table in tables:\n        df = table.df\n        text = df.to_string().lower()\n        \n        # Identify table type\n        if 'revenue' in text or 'sales' in text:\n            if 'operating income' in text or 'net income' in text:\n                financial_data['income_statement'] = df\n        elif 'asset' in text and 'liabilities' in text:\n            financial_data['balance_sheet'] = df\n        elif 'cash flow' in text or 'operating activities' in text:\n            financial_data['cash_flow'] = df\n        else:\n            financial_data['other_tables'].append({\n                'page': table.page,\n                'data': df,\n                'accuracy': table.accuracy\n            })\n    \n    return financial_data\n\nfinancials = extract_financial_tables('annual_report.pdf')\nif financials['income_statement'] is not None:\n    print(\"Income Statement found:\")\n    print(financials['income_statement'])\n```\n\n### Example 2: Scientific Data Extraction\n```python\nimport camelot\nimport pandas as pd\n\ndef extract_research_data(pdf_path, pages='all'):\n    \"\"\"Extract data tables from research paper.\"\"\"\n    \n    # Try lattice for bordered tables\n    tables = camelot.read_pdf(pdf_path, pages=pages, flavor='lattice')\n    \n    if not tables or all(t.accuracy \u003C 70 for t in tables):\n        # Fall back to stream for borderless\n        tables = camelot.read_pdf(pdf_path, pages=pages, flavor='stream')\n    \n    extracted_data = []\n    \n    for table in tables:\n        df = table.df\n        \n        # Clean up the DataFrame\n        # Set first row as header if it looks like one\n        if not df.iloc[0].str.contains(r'\\d').any():\n            df.columns = df.iloc[0]\n            df = df[1:]\n            df = df.reset_index(drop=True)\n        \n        extracted_data.append({\n            'page': table.page,\n            'accuracy': table.accuracy,\n            'data': df\n        })\n    \n    return extracted_data\n\ndata = extract_research_data('research_paper.pdf')\nfor i, item in enumerate(data):\n    print(f\"Table {i+1} (Page {item['page']}, Accuracy: {item['accuracy']}%):\")\n    print(item['data'].head())\n```\n\n### Example 3: Invoice Line Items\n```python\nimport camelot\n\ndef extract_invoice_items(pdf_path):\n    \"\"\"Extract line items from invoice.\"\"\"\n    \n    # Usually invoices have bordered tables\n    tables = camelot.read_pdf(pdf_path, flavor='lattice')\n    \n    line_items = []\n    \n    for table in tables:\n        df = table.df\n        \n        # Look for table with typical invoice columns\n        header_text = ' '.join(df.iloc[0].astype(str)).lower()\n        \n        if any(term in header_text for term in ['quantity', 'qty', 'amount', 'price', 'description']):\n            # This looks like a line items table\n            df.columns = df.iloc[0]\n            df = df[1:]\n            \n            for _, row in df.iterrows():\n                item = {}\n                for col in df.columns:\n                    col_lower = str(col).lower()\n                    value = row[col]\n                    \n                    if 'desc' in col_lower or 'item' in col_lower:\n                        item['description'] = value\n                    elif 'qty' in col_lower or 'quantity' in col_lower:\n                        item['quantity'] = value\n                    elif 'price' in col_lower or 'rate' in col_lower:\n                        item['unit_price'] = value\n                    elif 'amount' in col_lower or 'total' in col_lower:\n                        item['amount'] = value\n                \n                if item:\n                    line_items.append(item)\n    \n    return line_items\n\nitems = extract_invoice_items('invoice.pdf')\nfor item in items:\n    print(item)\n```\n\n### Example 4: Table Comparison\n```python\nimport camelot\nimport pandas as pd\n\ndef compare_pdf_tables(pdf1_path, pdf2_path):\n    \"\"\"Compare tables between two PDF versions.\"\"\"\n    \n    tables1 = camelot.read_pdf(pdf1_path)\n    tables2 = camelot.read_pdf(pdf2_path)\n    \n    comparisons = []\n    \n    # Match tables by shape and position\n    for t1 in tables1:\n        best_match = None\n        best_score = 0\n        \n        for t2 in tables2:\n            if t1.df.shape == t2.df.shape:\n                # Calculate similarity\n                try:\n                    similarity = (t1.df == t2.df).mean().mean()\n                    if similarity > best_score:\n                        best_score = similarity\n                        best_match = t2\n                except:\n                    pass\n        \n        if best_match:\n            comparisons.append({\n                'page1': t1.page,\n                'page2': best_match.page,\n                'similarity': best_score,\n                'identical': best_score == 1.0,\n                'diff': pd.DataFrame(t1.df != best_match.df)\n            })\n    \n    return comparisons\n\ncomparison = compare_pdf_tables('report_v1.pdf', 'report_v2.pdf')\n```\n\n## Limitations\n\n- Encrypted PDFs not supported\n- Image-based PDFs need OCR preprocessing\n- Very complex merged cells may need tuning\n- Rotated tables require preprocessing\n- Large PDFs may need page-by-page processing\n\n## Installation\n\n```bash\npip install camelot-py[cv]\n\n# Additional dependencies\n# macOS\nbrew install ghostscript tcl-tk\n\n# Ubuntu\napt-get install ghostscript python3-tk\n```\n\n## Resources\n\n- [camelot Documentation](https:\u002F\u002Fcamelot-py.readthedocs.io\u002F)\n- [GitHub Repository](https:\u002F\u002Fgithub.com\u002Fcamelot-dev\u002Fcamelot)\n- [Comparison with Other Tools](https:\u002F\u002Fcamelot-py.readthedocs.io\u002Fen\u002Fmaster\u002Fuser\u002Fintro.html#why-camelot)\n","# Table Extractor Skill\n\n## Overview\n\nThis skill enables precise extraction of tables from PDF documents using **camelot** - the gold standard for PDF table extraction. Handle complex tables with merged cells, borderless tables, and multi-page layouts with high accuracy.\n\n## How to Use\n\n1. Provide the PDF containing tables\n2. Optionally specify pages or table detection method\n3. I'll extract tables as pandas DataFrames\n\n**Example prompts:**\n- \"Extract all tables from this PDF\"\n- \"Get the table on page 5 of this report\"\n- \"Extract borderless tables from this document\"\n- \"Convert PDF tables to Excel format\"\n\n## Domain Knowledge\n\n### camelot Fundamentals\n\n```python\nimport camelot\n\n# Extract tables from PDF\ntables = camelot.read_pdf('document.pdf')\n\n# Access results\nprint(f\"Found {len(tables)} tables\")\n\n# Get first table as DataFrame\ndf = tables[0].df\nprint(df)\n```\n\n### Extraction Methods\n\n| Method | Use Case | Description |\n|--------|----------|-------------|\n| `lattice` | Bordered tables | Detects table by lines\u002Fborders |\n| `stream` | Borderless tables | Uses text positioning |\n\n```python\n# Lattice method (default) - for tables with visible borders\ntables = camelot.read_pdf('document.pdf', flavor='lattice')\n\n# Stream method - for borderless tables\ntables = camelot.read_pdf('document.pdf', flavor='stream')\n```\n\n### Page Selection\n\n```python\n# Single page\ntables = camelot.read_pdf('document.pdf', pages='1')\n\n# Multiple pages\ntables = camelot.read_pdf('document.pdf', pages='1,3,5')\n\n# Page range\ntables = camelot.read_pdf('document.pdf', pages='1-5')\n\n# All pages\ntables = camelot.read_pdf('document.pdf', pages='all')\n```\n\n### Advanced Options\n\n#### Lattice Options\n```python\ntables = camelot.read_pdf(\n    'document.pdf',\n    flavor='lattice',\n    line_scale=40,              # Line detection sensitivity\n    copy_text=['h', 'v'],       # Copy text across merged cells\n    shift_text=['l', 't'],      # Shift text alignment\n    split_text=True,            # Split text at newlines\n    flag_size=True,             # Flag super\u002Fsubscripts\n    strip_text='\\n',            # Characters to strip\n    process_background=False,   # Process background lines\n)\n```\n\n#### Stream Options\n```python\ntables = camelot.read_pdf(\n    'document.pdf',\n    flavor='stream',\n    edge_tol=500,               # Edge tolerance\n    row_tol=10,                 # Row tolerance\n    column_tol=0,               # Column tolerance\n    strip_text='\\n',            # Characters to strip\n)\n```\n\n### Table Area Specification\n\n```python\n# Extract from specific area (x1, y1, x2, y2)\n# Coordinates from bottom-left, in PDF points (72 points = 1 inch)\ntables = camelot.read_pdf(\n    'document.pdf',\n    table_areas=['72,720,540,400'],  # One area\n)\n\n# Multiple areas\ntables = camelot.read_pdf(\n    'document.pdf',\n    table_areas=['72,720,540,400', '72,380,540,200'],\n)\n```\n\n### Column Specification\n\n```python\n# Manually specify column positions (for stream method)\ntables = camelot.read_pdf(\n    'document.pdf',\n    flavor='stream',\n    columns=['100,200,300,400'],  # X positions of column separators\n)\n```\n\n### Working with Results\n\n```python\nimport camelot\n\ntables = camelot.read_pdf('document.pdf')\n\nfor i, table in enumerate(tables):\n    # Access DataFrame\n    df = table.df\n    \n    # Table metadata\n    print(f\"Table {i+1}:\")\n    print(f\"  Page: {table.page}\")\n    print(f\"  Accuracy: {table.accuracy}\")\n    print(f\"  Whitespace: {table.whitespace}\")\n    print(f\"  Order: {table.order}\")\n    print(f\"  Shape: {df.shape}\")\n    \n    # Parsing report\n    report = table.parsing_report\n    print(f\"  Report: {report}\")\n```\n\n### Export Options\n\n```python\nimport camelot\n\ntables = camelot.read_pdf('document.pdf')\n\n# Export to CSV\ntables[0].to_csv('table.csv')\n\n# Export to Excel\ntables[0].to_excel('table.xlsx')\n\n# Export to JSON\ntables[0].to_json('table.json')\n\n# Export to HTML\ntables[0].to_html('table.html')\n\n# Export all tables\nfor i, table in enumerate(tables):\n    table.to_excel(f'table_{i+1}.xlsx')\n```\n\n### Visual Debugging\n\n```python\nimport camelot\n\n# Enable visual debugging\ntables = camelot.read_pdf('document.pdf')\n\n# Plot detected table areas\ncamelot.plot(tables[0], kind='contour').show()\n\n# Plot text on table\ncamelot.plot(tables[0], kind='text').show()\n\n# Plot detected lines (lattice only)\ncamelot.plot(tables[0], kind='joint').show()\ncamelot.plot(tables[0], kind='line').show()\n\n# Save plot\nfig = camelot.plot(tables[0])\nfig.savefig('debug.png')\n```\n\n### Handling Multi-page Tables\n\n```python\nimport camelot\nimport pandas as pd\n\ndef extract_multipage_table(pdf_path, pages='all'):\n    \"\"\"Extract and combine tables that span multiple pages.\"\"\"\n    \n    tables = camelot.read_pdf(pdf_path, pages=pages)\n    \n    # Group tables by similar structure (columns)\n    table_groups = {}\n    \n    for table in tables:\n        cols = tuple(table.df.columns)\n        if cols not in table_groups:\n            table_groups[cols] = []\n        table_groups[cols].append(table.df)\n    \n    # Combine similar tables\n    combined = []\n    for cols, dfs in table_groups.items():\n        if len(dfs) > 1:\n            # Combine and deduplicate header rows\n            combined_df = pd.concat(dfs, ignore_index=True)\n            combined.append(combined_df)\n        else:\n            combined.append(dfs[0])\n    \n    return combined\n```\n\n## Best Practices\n\n1. **Try Both Methods**: Lattice for bordered, stream for borderless\n2. **Check Accuracy Score**: Above 90% is usually good\n3. **Use Visual Debugging**: Understand extraction results\n4. **Specify Areas**: For PDFs with multiple table types\n5. **Handle Headers**: First row often needs special treatment\n\n## Common Patterns\n\n### Batch Table Extraction\n```python\nimport camelot\nfrom pathlib import Path\nimport pandas as pd\n\ndef batch_extract_tables(input_dir, output_dir):\n    \"\"\"Extract tables from all PDFs in directory.\"\"\"\n    \n    input_path = Path(input_dir)\n    output_path = Path(output_dir)\n    output_path.mkdir(exist_ok=True)\n    \n    results = []\n    \n    for pdf_file in input_path.glob('*.pdf'):\n        try:\n            tables = camelot.read_pdf(str(pdf_file), pages='all')\n            \n            for i, table in enumerate(tables):\n                # Skip low accuracy tables\n                if table.accuracy \u003C 80:\n                    continue\n                \n                output_file = output_path \u002F f\"{pdf_file.stem}_table_{i+1}.xlsx\"\n                table.to_excel(str(output_file))\n                \n                results.append({\n                    'source': str(pdf_file),\n                    'table': i + 1,\n                    'page': table.page,\n                    'accuracy': table.accuracy,\n                    'output': str(output_file)\n                })\n        \n        except Exception as e:\n            results.append({\n                'source': str(pdf_file),\n                'error': str(e)\n            })\n    \n    return results\n```\n\n### Auto-detect Table Method\n```python\nimport camelot\n\ndef smart_extract_tables(pdf_path, pages='1'):\n    \"\"\"Try both methods and return best results.\"\"\"\n    \n    # Try lattice first\n    lattice_tables = camelot.read_pdf(pdf_path, pages=pages, flavor='lattice')\n    \n    # Try stream\n    stream_tables = camelot.read_pdf(pdf_path, pages=pages, flavor='stream')\n    \n    # Compare and return best\n    results = []\n    \n    if lattice_tables and lattice_tables[0].accuracy > 70:\n        results.extend(lattice_tables)\n    elif stream_tables:\n        results.extend(stream_tables)\n    \n    return results\n```\n\n## Examples\n\n### Example 1: Financial Statement Extraction\n```python\nimport camelot\nimport pandas as pd\n\ndef extract_financial_tables(pdf_path):\n    \"\"\"Extract financial tables from annual report.\"\"\"\n    \n    # Extract all tables\n    tables = camelot.read_pdf(pdf_path, pages='all', flavor='lattice')\n    \n    financial_data = {\n        'income_statement': None,\n        'balance_sheet': None,\n        'cash_flow': None,\n        'other_tables': []\n    }\n    \n    for table in tables:\n        df = table.df\n        text = df.to_string().lower()\n        \n        # Identify table type\n        if 'revenue' in text or 'sales' in text:\n            if 'operating income' in text or 'net income' in text:\n                financial_data['income_statement'] = df\n        elif 'asset' in text and 'liabilities' in text:\n            financial_data['balance_sheet'] = df\n        elif 'cash flow' in text or 'operating activities' in text:\n            financial_data['cash_flow'] = df\n        else:\n            financial_data['other_tables'].append({\n                'page': table.page,\n                'data': df,\n                'accuracy': table.accuracy\n            })\n    \n    return financial_data\n\nfinancials = extract_financial_tables('annual_report.pdf')\nif financials['income_statement'] is not None:\n    print(\"Income Statement found:\")\n    print(financials['income_statement'])\n```\n\n### Example 2: Scientific Data Extraction\n```python\nimport camelot\nimport pandas as pd\n\ndef extract_research_data(pdf_path, pages='all'):\n    \"\"\"Extract data tables from research paper.\"\"\"\n    \n    # Try lattice for bordered tables\n    tables = camelot.read_pdf(pdf_path, pages=pages, flavor='lattice')\n    \n    if not tables or all(t.accuracy \u003C 70 for t in tables):\n        # Fall back to stream for borderless\n        tables = camelot.read_pdf(pdf_path, pages=pages, flavor='stream')\n    \n    extracted_data = []\n    \n    for table in tables:\n        df = table.df\n        \n        # Clean up the DataFrame\n        # Set first row as header if it looks like one\n        if not df.iloc[0].str.contains(r'\\d').any():\n            df.columns = df.iloc[0]\n            df = df[1:]\n            df = df.reset_index(drop=True)\n        \n        extracted_data.append({\n            'page': table.page,\n            'accuracy': table.accuracy,\n            'data': df\n        })\n    \n    return extracted_data\n\ndata = extract_research_data('research_paper.pdf')\nfor i, item in enumerate(data):\n    print(f\"Table {i+1} (Page {item['page']}, Accuracy: {item['accuracy']}%):\")\n    print(item['data'].head())\n```\n\n### Example 3: Invoice Line Items\n```python\nimport camelot\n\ndef extract_invoice_items(pdf_path):\n    \"\"\"Extract line items from invoice.\"\"\"\n    \n    # Usually invoices have bordered tables\n    tables = camelot.read_pdf(pdf_path, flavor='lattice')\n    \n    line_items = []\n    \n    for table in tables:\n        df = table.df\n        \n        # Look for table with typical invoice columns\n        header_text = ' '.join(df.iloc[0].astype(str)).lower()\n        \n        if any(term in header_text for term in ['quantity', 'qty', 'amount', 'price', 'description']):\n            # This looks like a line items table\n            df.columns = df.iloc[0]\n            df = df[1:]\n            \n            for _, row in df.iterrows():\n                item = {}\n                for col in df.columns:\n                    col_lower = str(col).lower()\n                    value = row[col]\n                    \n                    if 'desc' in col_lower or 'item' in col_lower:\n                        item['description'] = value\n                    elif 'qty' in col_lower or 'quantity' in col_lower:\n                        item['quantity'] = value\n                    elif 'price' in col_lower or 'rate' in col_lower:\n                        item['unit_price'] = value\n                    elif 'amount' in col_lower or 'total' in col_lower:\n                        item['amount'] = value\n                \n                if item:\n                    line_items.append(item)\n    \n    return line_items\n\nitems = extract_invoice_items('invoice.pdf')\nfor item in items:\n    print(item)\n```\n\n### Example 4: Table Comparison\n```python\nimport camelot\nimport pandas as pd\n\ndef compare_pdf_tables(pdf1_path, pdf2_path):\n    \"\"\"Compare tables between two PDF versions.\"\"\"\n    \n    tables1 = camelot.read_pdf(pdf1_path)\n    tables2 = camelot.read_pdf(pdf2_path)\n    \n    comparisons = []\n    \n    # Match tables by shape and position\n    for t1 in tables1:\n        best_match = None\n        best_score = 0\n        \n        for t2 in tables2:\n            if t1.df.shape == t2.df.shape:\n                # Calculate similarity\n                try:\n                    similarity = (t1.df == t2.df).mean().mean()\n                    if similarity > best_score:\n                        best_score = similarity\n                        best_match = t2\n                except:\n                    pass\n        \n        if best_match:\n            comparisons.append({\n                'page1': t1.page,\n                'page2': best_match.page,\n                'similarity': best_score,\n                'identical': best_score == 1.0,\n                'diff': pd.DataFrame(t1.df != best_match.df)\n            })\n    \n    return comparisons\n\ncomparison = compare_pdf_tables('report_v1.pdf', 'report_v2.pdf')\n```\n\n## Limitations\n\n- Encrypted PDFs not supported\n- Image-based PDFs need OCR preprocessing\n- Very complex merged cells may need tuning\n- Rotated tables require preprocessing\n- Large PDFs may need page-by-page processing\n\n## Installation\n\n```bash\npip install camelot-py[cv]\n\n# Additional dependencies\n# macOS\nbrew install ghostscript tcl-tk\n\n# Ubuntu\napt-get install ghostscript python3-tk\n```\n\n## Resources\n\n- [camelot Documentation](https:\u002F\u002Fcamelot-py.readthedocs.io\u002F)\n- [GitHub Repository](https:\u002F\u002Fgithub.com\u002Fcamelot-dev\u002Fcamelot)\n- [Comparison with Other Tools](https:\u002F\u002Fcamelot-py.readthedocs.io\u002Fen\u002Fmaster\u002Fuser\u002Fintro.html#why-camelot)\n",{"mcp":40,"name":5,"tags":44,"author":46,"models":47,"license":15,"version":55,"category":27,"languages":56,"department":57,"description":7,"capabilities":58},{"tools":41,"server":43},[42],"extract_tables_from_pdf","office-mcp",[19,24,45,31],"pdf","claude-office-skills",{"compatible":48,"recommended":52},[49,50,51],"claude-3-5-sonnet","gpt-4","gpt-4o",[53,54],"claude-sonnet-4","claude-opus-4","1.0",[29,30],"All",[59,60],"table_extraction","data_structuring","main","3efae68c898153694a2f4aad309c7ff9847b5602","installed-skills\u002Ftable-extractor",0,"https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config","https:\u002F\u002Fgithub.com\u002Flegout","2026-04-28 16:32:33",{"source":8,"skillName":5,"commands":69,"prompt":79,"zipAvailable":80},[70,73,76],{"tool":71,"command":72},"npx","npx skills add legout\u002Fpi-config --skill table-extractor",{"tool":74,"command":75},"bunx","bunx skills add legout\u002Fpi-config --skill table-extractor",{"tool":77,"command":78},"pnpm","pnpm dlx skills add legout\u002Fpi-config --skill table-extractor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Ftable-extractor\u002FSKILL.md",true,[],[83,109,122,135,158,178],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":35},"01M6KGW7MYKZ8MWFKN1V8ZJ2EG","visual-explainer","Generate beautiful, self-contained HTML pages that visually explain systems, code changes, plans, and data. Use when the user asks for a diagram, architecture overview, diff review, plan review, project recap, comparison table, or any visual explanation of technical concepts. Also use proactively when you are about to render a complex ASCII table (4+ rows or 3+ columns) — present it as a styled HTML page instead.","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Fskills\u002Fvisual-explainer\u002FSKILL.md",[],[90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,19,105,106,107,108],"visual explainer","explainer","visual","for","use","surf","concepts","you","ascii","ascii table","as","present","project","files","view","plan","generate","architecture","image",{"skillNo":110,"name":111,"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":112,"categories":113,"keywords":114,"publishedAt":35},"01M6KGSWF2R22Z63PAY5NT6GRY","smart-ocr","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fsmart-ocr\u002FSKILL.md",[],[115,116,117,29,30,28,118,27,25,24,23,119,22,21,120,121,33,32],"ocr","smart ocr","multilingual","text","support","processing","paddleocr",{"skillNo":123,"name":124,"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":125,"categories":126,"keywords":127,"publishedAt":35},"01M6KGMKKFNC1PRNX2W3E243DR","html-slides","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fhtml-slides\u002FSKILL.md",[],[128,129,130,33,131,132,30,29,25,23,133,22,134,32],"slides","html","html slides","presentation","revealjs","web","pptx",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":139,"licenseFileUrl":6,"sourceHtmlUrl":140,"categories":141,"keywords":142,"publishedAt":35},"01M6KGJGVM0TWW632Y6VQQV2WN","using-streamlit-session-state","Using st.session_state to manage state across Streamlit reruns. Use when persisting data, handling widget state, implementing callbacks, or debugging state issues. Covers initialization patterns, widget-state association, and common gotchas.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fdeveloping-with-streamlit\u002Fskills\u002Fusing-streamlit-session-state\u002FSKILL.md",[],[143,144,145,146,147,148,149,150,151,152,153,154,155,156,94,157,26],"state","session state","using streamlit session state","streamlit","session","debugging","issues","initialization","implementing","Callbacks","widget","across","patterns","manage","common",{"skillNo":159,"name":160,"nameZh":6,"description":161,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":139,"licenseFileUrl":6,"sourceHtmlUrl":162,"categories":163,"keywords":164,"publishedAt":35},"01M6KGJD12GJB7W0ZG66JK00F6","using-streamlit-markdown","Covers all Markdown features in Streamlit including GitHub-flavored syntax plus Streamlit extensions like colored text, badges, Material icons, and LaTeX. Use when formatting text, labels, tooltips, or any text-rendering element.","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fdeveloping-with-streamlit\u002Fskills\u002Fusing-streamlit-markdown\u002FSKILL.md",[],[165,146,166,118,167,168,169,170,171,172,173,94,174,175,176,177],"using streamlit markdown","markdown","labels","features","extensions","rendering","material","element","formatting","syntax","LaTeX","icons","github",{"skillNo":179,"name":180,"nameZh":6,"description":181,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":139,"licenseFileUrl":6,"sourceHtmlUrl":182,"categories":183,"keywords":184,"publishedAt":35},"01M6KGJ7M5Q1RHBZ72MCWTM9GQ","using-streamlit-layouts","Structuring Streamlit app layouts. Use when placing content in sidebars, columns, containers, or dialogs. Covers sidebar usage, column limits, horizontal containers, dialogs, and bordered cards.","https:\u002F\u002Fgithub.com\u002Flegout\u002Fpi-config\u002Fblob\u002Fmain\u002Finstalled-skills\u002Fdeveloping-with-streamlit\u002Fskills\u002Fusing-streamlit-layouts\u002FSKILL.md",[],[185,146,186,187,188,189,190,94,191],"using streamlit layouts","containers","usage","columns","column","app","content"]