[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M72A837KJZ6B4AXVM1080W70":3,"skill-same:01M72A837KJZ6B4AXVM1080W70":70},{"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":50,"commitSha":51,"skillDirectory":5,"forksCount":52,"repositoryHtmlUrl":53,"repositoryHomepageUrl":6,"ownerHtmlUrl":54,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":55,"install":56,"resources":69},"01M72A837KJZ6B4AXVM1080W70","table-extractor",null,">","claude-office-skills\u002Fskills","claude-office-skills","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F258027507?v=4","01M729XQC9FBRQ54AQZS0KY3ZK","AGI Lab","01M729XQCYW6WF9GY762P9RNQJ",575,"MIT","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Ftable-extractor\u002FSKILL.md",[],[],"2026-11-10 18:39:20",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":24,"name":5,"tags":28,"author":9,"models":33,"license":15,"version":41,"category":42,"languages":43,"department":46,"description":7,"capabilities":47},{"tools":25,"server":27},[26],"extract_tables_from_pdf","office-mcp",[29,30,31,32],"table","extraction","pdf","camelot",{"compatible":34,"recommended":38},[35,36,37],"claude-3-5-sonnet","gpt-4","gpt-4o",[39,40],"claude-sonnet-4","claude-opus-4","1.0","parsing",[44,45],"en","zh","All",[48,49],"table_extraction","data_structuring","main","9c4c7d5cd2813a8936bf2c9fdb174ea883b85a11",105,"https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills","2026-01-31 22:03:56",{"source":8,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add claude-office-skills\u002Fskills --skill table-extractor",{"tool":62,"command":63},"bunx","bunx skills add claude-office-skills\u002Fskills --skill table-extractor",{"tool":65,"command":66},"pnpm","pnpm dlx skills add claude-office-skills\u002Fskills --skill table-extractor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Ftable-extractor\u002FSKILL.md",true,[],[71,78,84,91,98,105],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M72A0X7X4TWS4ZWTEK8TJEC8","devops-automation","DevOps and IT Ops automation - CI\u002FCD, monitoring, incident management, and infrastructure workflows","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdevops-automation\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"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":81,"categories":82,"keywords":83,"publishedAt":19},"01M72A0VPXF4Q5F48TPDG6S10Q","dev-slides","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdev-slides\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M72A0Q1T0KN60CR3PAD93J6T","deep-research","Conduct comprehensive research on any topic. Synthesize information from multiple angles, provide structured analysis, and generate detailed research reports.","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdeep-research\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M72A0KWAYEWQJMDRGC0WTT7V","dcf-valuation","Build Discounted Cash Flow (DCF) valuation models. Calculate intrinsic value with customizable assumptions. Generate professional valuation reports.","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdcf-valuation\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M72A0GVWRZ3HZNXMW3RB5CF9","Database Sync","Automate database synchronization, replication, migration, and cross-platform data integration","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdatabase-sync\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":19},"01M72A0E16K862EDP0QYEAC9HJ","data-pipeline","Data pipeline and ETL automation - extract, transform, load workflows for data integration and analytics","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdata-pipeline\u002FSKILL.md",[],[]]