[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EGA7P5RFHGNTFEF2HFNE3D":3,"skill-same:01M6EGA7P5RFHGNTFEF2HFNE3D":47},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M6EGA7P5RFHGNTFEF2HFNE3D","table-extractor",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Ftable-extractor\u002FSKILL.md",[],[18,19],"table","table extractor","2026-11-10 10:12:30",false,"# Table Extractor\n\n## Overview\n\nExtract tables from PDF documents with high accuracy using camelot-py. Handles complex table structures including merged cells, multi-line rows, spanning headers, and borderless tables. Outputs clean DataFrames that can be exported to CSV, Excel, or JSON.\n\n## Instructions\n\nWhen a user asks you to extract tables from a PDF, follow this process:\n\n### Step 1: Install and verify dependencies\n\n```bash\n# Install camelot and its dependencies\npip install \"camelot-py[base]\" ghostscript opencv-python-headless pandas\n\n# Verify ghostscript is available (required by camelot)\ngs --version 2>\u002Fdev\u002Fnull || echo \"Install ghostscript: sudo apt install ghostscript\"\n```\n\nIf ghostscript is not available, fall back to pdfplumber:\n\n```bash\npip install pdfplumber pandas\n```\n\n### Step 2: Inspect the PDF to locate tables\n\n```python\nimport camelot\n\n# Quick scan: how many tables are in the document?\ntables = camelot.read_pdf(\"document.pdf\", pages=\"all\", flavor=\"lattice\")\nprint(f\"Found {len(tables)} tables using lattice detection\")\n\n# If no tables found, try stream detection (for borderless tables)\nif len(tables) == 0:\n    tables = camelot.read_pdf(\"document.pdf\", pages=\"all\", flavor=\"stream\")\n    print(f\"Found {len(tables)} tables using stream detection\")\n\n# Summary of each table\nfor i, table in enumerate(tables):\n    print(f\"\\nTable {i}: {table.shape[0]} rows x {table.shape[1]} cols (page {table.page})\")\n    print(f\"Accuracy: {table.accuracy:.1f}%\")\n    print(table.df.head(3))\n```\n\n### Step 3: Choose the right extraction flavor\n\n**Lattice flavor** (for tables with visible borders\u002Fgridlines):\n\n```python\ntables = camelot.read_pdf(\n    \"document.pdf\",\n    pages=\"1,2,3\",        # Specific pages\n    flavor=\"lattice\",\n    line_scale=40,         # Adjust line detection sensitivity\n    process_background=True # Detect lines on colored backgrounds\n)\n```\n\n**Stream flavor** (for borderless tables, whitespace-separated):\n\n```python\ntables = camelot.read_pdf(\n    \"document.pdf\",\n    pages=\"1\",\n    flavor=\"stream\",\n    edge_tol=50,          # Tolerance for edge detection\n    row_tol=10,           # Tolerance for grouping text into rows\n    columns=[\"72,200,350,500\"]  # Manual column boundaries if auto-detect fails\n)\n```\n\n### Step 4: Clean and process extracted tables\n\n```python\nimport pandas as pd\n\nfor i, table in enumerate(tables):\n    df = table.df\n\n    # Promote first row to header if it contains column names\n    if df.iloc[0].str.match(r'^[A-Za-z]').all():\n        df.columns = df.iloc[0]\n        df = df[1:].reset_index(drop=True)\n\n    # Clean whitespace and newlines within cells\n    df = df.apply(lambda col: col.str.strip().str.replace(r'\\n', ' ', regex=True))\n\n    # Remove completely empty rows\n    df = df.dropna(how='all').replace('', pd.NA).dropna(how='all')\n\n    # Convert numeric columns\n    for col in df.columns:\n        try:\n            df[col] = pd.to_numeric(df[col].str.replace(',', '').str.replace('$', ''))\n        except (ValueError, AttributeError):\n            pass  # Keep as string\n\n    print(f\"\\nCleaned Table {i}:\")\n    print(df.head())\n```\n\n### Step 5: Handle complex table structures\n\n**Merged cells and spanning headers:**\n\n```python\n# Forward-fill merged cells (common in row headers)\ndf.iloc[:, 0] = df.iloc[:, 0].replace('', pd.NA).ffill()\n\n# Handle multi-level column headers\nif df.iloc[0:2].apply(lambda x: x.str.len().mean()).mean() \u003C 20:\n    # Combine first two rows as multi-level header\n    new_cols = df.iloc[0] + \" - \" + df.iloc[1]\n    df.columns = new_cols.str.strip(\" - \")\n    df = df[2:].reset_index(drop=True)\n```\n\n**Tables spanning multiple pages:**\n\n```python\n# Extract from all pages and concatenate\nall_tables = camelot.read_pdf(\"document.pdf\", pages=\"all\", flavor=\"lattice\")\n\n# Group tables that are continuations (same column count)\ngroups = {}\nfor t in all_tables:\n    key = t.shape[1]\n    groups.setdefault(key, []).append(t.df)\n\nfor col_count, dfs in groups.items():\n    combined = pd.concat(dfs, ignore_index=True)\n    # Remove duplicate header rows that appear at page breaks\n    combined = combined[~combined.duplicated(keep='first')]\n```\n\n### Step 6: Export the results\n\n```python\n# CSV (one file per table)\nfor i, table in enumerate(tables):\n    table.df.to_csv(f\"table_{i+1}.csv\", index=False)\n\n# Excel (all tables as separate sheets)\nwith pd.ExcelWriter(\"extracted_tables.xlsx\") as writer:\n    for i, table in enumerate(tables):\n        table.df.to_excel(writer, sheet_name=f\"Table_{i+1}\", index=False)\n\n# JSON\nfor i, table in enumerate(tables):\n    table.df.to_json(f\"table_{i+1}.json\", orient=\"records\", indent=2)\n\nprint(f\"Exported {len(tables)} tables\")\n```\n\n## Examples\n\n### Example 1: Extract financial tables from an annual report\n\n**User request:** \"Extract all tables from this annual report PDF\"\n\n**Actions:**\n\n1. Scan all pages with lattice flavor (financial reports typically have bordered tables)\n2. Identify income statement, balance sheet, and cash flow tables by column headers\n3. Clean numeric values (remove $, commas, parentheses for negatives)\n4. Export each table to a separate CSV and combine into one Excel workbook\n\n**Output:** \"Extracted 7 tables across 42 pages. Exported to extracted_tables.xlsx with sheets: Income_Statement, Balance_Sheet, Cash_Flow, Revenue_Breakdown, Expenses, Quarterly_Summary, KPIs.\"\n\n### Example 2: Extract a specific table from a research paper\n\n**User request:** \"Get the results table from page 8 of this paper\"\n\n**Actions:**\n\n1. Target page 8 specifically: `camelot.read_pdf(\"paper.pdf\", pages=\"8\")`\n2. If multiple tables on the page, show summaries and let the user pick\n3. Clean the extracted table and handle any multi-line cells\n4. Export as CSV\n\n**Output:** A single CSV file with the results table, plus a preview of the first few rows printed to the console.\n\n### Example 3: Batch process multiple PDFs\n\n**User request:** \"Extract the summary table from each of these 20 monthly reports\"\n\n**Actions:**\n\n```python\nimport glob\n\nresults = []\nfor pdf_path in sorted(glob.glob(\"reports\u002F*.pdf\")):\n    tables = camelot.read_pdf(pdf_path, pages=\"1\", flavor=\"lattice\")\n    if tables:\n        df = tables[0].df  # First table on first page\n        df[\"source_file\"] = pdf_path\n        results.append(df)\n\ncombined = pd.concat(results, ignore_index=True)\ncombined.to_csv(\"all_summaries.csv\", index=False)\n```\n\n**Output:** A single CSV combining the summary table from all 20 reports with a source_file column for traceability.\n\n## Guidelines\n\n- Always try `lattice` flavor first (bordered tables). Fall back to `stream` for borderless tables.\n- Check the `accuracy` score on each table. Below 80% indicates extraction issues that need manual review.\n- For scanned PDFs, run OCR first (e.g., `ocrmypdf`) before table extraction.\n- When camelot struggles, try pdfplumber as an alternative: `page.extract_table(table_settings={...})`.\n- Clean numeric data aggressively: remove currency symbols, commas, and handle parenthesized negatives.\n- For tables with merged cells, use forward-fill on the appropriate columns.\n- When extracting from multiple pages, watch for repeated header rows at page breaks.\n- Always preview the extracted data before exporting to catch alignment or parsing issues.\n- Report extraction quality metrics (accuracy, row\u002Fcolumn count) so the user can verify correctness.\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002FTerminalSkills\u002Fskills\u002Ftable-extractor",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill table-extractor",{"tool":39,"command":40},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill table-extractor",{"tool":42,"command":43},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill table-extractor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FTerminalSkills\u002Fskills\u002Ftable-extractor\u002FSKILL.md",true,[],[48,57,66,75,81,87],{"skillNo":49,"name":50,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":20},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[54,55,56],"model","model hierarchy","model hierarchy skill",{"skillNo":58,"name":59,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":20},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[63,64,65],"MCP","zoom","zoom mcp",{"skillNo":67,"name":68,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":20},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[72,73,74,64],"sdk","zoom apps sdk","apps",{"skillNo":76,"name":77,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":20},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[77],{"skillNo":82,"name":83,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":20},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[83],{"skillNo":88,"name":89,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":20},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[89]]