[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6MVCJK42TK7ZENPJT8JEGDZ":3,"skill-same:01M6MVCJK42TK7ZENPJT8JEGDZ":84},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":56,"commitSha":57,"skillDirectory":58,"forksCount":59,"repositoryHtmlUrl":60,"repositoryHomepageUrl":6,"ownerHtmlUrl":61,"ownerBlogUrl":6,"ownerDescription":62,"updatedAt":63,"install":64,"resources":77},"01M6MVCJK42TK7ZENPJT8JEGDZ","data-extractor",null,"Extract structured data from any document format using unstructured - unified document processing","Kernel8901\u002Fai-agent-skills-classification","Kernel8901","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F72647553?v=4","01M6KV388J2H5PNC8D8P940BJD","01M6KV38CS5B3AY63RKZB410YM",7,"MIT","https:\u002F\u002Fgithub.com\u002FKernel8901\u002Fai-agent-skills-classification\u002Fblob\u002Fmain\u002FPDF及文件\u002Fdata-extractor\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"data extractor","data","format","unstructured","opus","sonnet","processing","io","document","operations","computer","structured data","parsing","execution","office","file","https","code","documents","github","2026-11-10 10:12:30",false,"---\nname: data-extractor\ndescription: Extract structured data from any document format using unstructured - unified document processing\nauthor: claude-office-skills\nversion: \"1.0\"\ntags: [extraction, unstructured, data, parsing, documents]\nmodels: [claude-sonnet-4, claude-opus-4]\ntools: [computer, code_execution, file_operations]\nlibrary:\n  name: unstructured\n  url: https:\u002F\u002Fgithub.com\u002FUnstructured-IO\u002Funstructured\n  stars: 14k\n---\n\n# Data Extractor Skill\n\n## Overview\n\nThis skill enables extraction of structured data from any document format using **unstructured** - a unified library for processing PDFs, Word docs, emails, HTML, and more. Get consistent, structured output regardless of input format.\n\n## How to Use\n\n1. Provide the document to process\n2. Optionally specify extraction options\n3. I'll extract structured elements with metadata\n\n**Example prompts:**\n- \"Extract all text and tables from this PDF\"\n- \"Parse this email and get the body, attachments, and metadata\"\n- \"Convert this HTML page to structured elements\"\n- \"Extract data from these mixed-format documents\"\n\n## Domain Knowledge\n\n### unstructured Fundamentals\n\n```python\nfrom unstructured.partition.auto import partition\n\n# Automatically detect and process any document\nelements = partition(\"document.pdf\")\n\n# Access extracted elements\nfor element in elements:\n    print(f\"Type: {type(element).__name__}\")\n    print(f\"Text: {element.text}\")\n    print(f\"Metadata: {element.metadata}\")\n```\n\n### Supported Formats\n\n| Format | Function | Notes |\n|--------|----------|-------|\n| PDF | `partition_pdf` | Native + scanned |\n| Word | `partition_docx` | Full structure |\n| PowerPoint | `partition_pptx` | Slides & notes |\n| Excel | `partition_xlsx` | Sheets & tables |\n| Email | `partition_email` | Body & attachments |\n| HTML | `partition_html` | Tags preserved |\n| Markdown | `partition_md` | Structure preserved |\n| Plain Text | `partition_text` | Basic parsing |\n| Images | `partition_image` | OCR extraction |\n\n### Element Types\n\n```python\nfrom unstructured.documents.elements import (\n    Title,\n    NarrativeText,\n    Text,\n    ListItem,\n    Table,\n    Image,\n    Header,\n    Footer,\n    PageBreak,\n    Address,\n    EmailAddress,\n)\n\n# Elements have consistent structure\nelement.text           # Raw text content\nelement.metadata       # Rich metadata\nelement.category       # Element type\nelement.id            # Unique identifier\n```\n\n### Auto Partition\n\n```python\nfrom unstructured.partition.auto import partition\n\n# Process any file type\nelements = partition(\n    filename=\"document.pdf\",\n    strategy=\"auto\",          # or \"fast\", \"hi_res\", \"ocr_only\"\n    include_metadata=True,\n    include_page_breaks=True,\n)\n\n# Filter by type\ntitles = [e for e in elements if isinstance(e, Title)]\ntables = [e for e in elements if isinstance(e, Table)]\n```\n\n### Format-Specific Partitioning\n\n```python\n# PDF with options\nfrom unstructured.partition.pdf import partition_pdf\n\nelements = partition_pdf(\n    filename=\"document.pdf\",\n    strategy=\"hi_res\",              # High quality extraction\n    infer_table_structure=True,     # Detect tables\n    include_page_breaks=True,\n    languages=[\"en\"],               # OCR language\n)\n\n# Word documents\nfrom unstructured.partition.docx import partition_docx\n\nelements = partition_docx(\n    filename=\"document.docx\",\n    include_metadata=True,\n)\n\n# HTML\nfrom unstructured.partition.html import partition_html\n\nelements = partition_html(\n    filename=\"page.html\",\n    include_metadata=True,\n)\n```\n\n### Working with Tables\n\n```python\nfrom unstructured.partition.auto import partition\n\nelements = partition(\"report.pdf\", infer_table_structure=True)\n\n# Extract tables\nfor element in elements:\n    if element.category == \"Table\":\n        print(\"Table found:\")\n        print(element.text)\n        \n        # Access structured table data\n        if hasattr(element, 'metadata') and element.metadata.text_as_html:\n            print(\"HTML:\", element.metadata.text_as_html)\n```\n\n### Metadata Access\n\n```python\nfrom unstructured.partition.auto import partition\n\nelements = partition(\"document.pdf\")\n\nfor element in elements:\n    meta = element.metadata\n    \n    # Common metadata fields\n    print(f\"Page: {meta.page_number}\")\n    print(f\"Filename: {meta.filename}\")\n    print(f\"Filetype: {meta.filetype}\")\n    print(f\"Coordinates: {meta.coordinates}\")\n    print(f\"Languages: {meta.languages}\")\n```\n\n### Chunking for AI\u002FRAG\n\n```python\nfrom unstructured.partition.auto import partition\nfrom unstructured.chunking.title import chunk_by_title\nfrom unstructured.chunking.basic import chunk_elements\n\n# Partition document\nelements = partition(\"document.pdf\")\n\n# Chunk by title (semantic chunks)\nchunks = chunk_by_title(\n    elements,\n    max_characters=1000,\n    combine_text_under_n_chars=200,\n)\n\n# Or basic chunking\nchunks = chunk_elements(\n    elements,\n    max_characters=500,\n    overlap=50,\n)\n\nfor chunk in chunks:\n    print(f\"Chunk ({len(chunk.text)} chars):\")\n    print(chunk.text[:100] + \"...\")\n```\n\n### Batch Processing\n\n```python\nfrom unstructured.partition.auto import partition\nfrom pathlib import Path\nfrom concurrent.futures import ThreadPoolExecutor\n\ndef process_document(file_path):\n    \"\"\"Process single document.\"\"\"\n    try:\n        elements = partition(str(file_path))\n        return {\n            'file': str(file_path),\n            'status': 'success',\n            'elements': len(elements),\n            'text': '\\n\\n'.join([e.text for e in elements])\n        }\n    except Exception as e:\n        return {\n            'file': str(file_path),\n            'status': 'error',\n            'error': str(e)\n        }\n\ndef batch_process(input_dir, max_workers=4):\n    \"\"\"Process all documents in directory.\"\"\"\n    input_path = Path(input_dir)\n    files = list(input_path.glob('*'))\n    \n    with ThreadPoolExecutor(max_workers=max_workers) as executor:\n        results = list(executor.map(process_document, files))\n    \n    return results\n```\n\n### Export Formats\n\n```python\nfrom unstructured.partition.auto import partition\nfrom unstructured.staging.base import elements_to_json, elements_to_dicts\n\nelements = partition(\"document.pdf\")\n\n# To JSON string\njson_str = elements_to_json(elements)\n\n# To list of dicts\ndicts = elements_to_dicts(elements)\n\n# To DataFrame\nimport pandas as pd\ndf = pd.DataFrame(dicts)\n```\n\n## Best Practices\n\n1. **Choose Strategy Wisely**: \"fast\" for speed, \"hi_res\" for accuracy\n2. **Enable Table Detection**: For documents with tables\n3. **Specify Language**: For better OCR on non-English docs\n4. **Chunk for RAG**: Use semantic chunking for AI applications\n5. **Handle Errors**: Some formats may fail gracefully\n\n## Common Patterns\n\n### Document to JSON\n```python\ndef document_to_json(file_path, output_path=None):\n    \"\"\"Convert document to structured JSON.\"\"\"\n    from unstructured.partition.auto import partition\n    from unstructured.staging.base import elements_to_json\n    import json\n    \n    elements = partition(file_path)\n    \n    # Create structured output\n    output = {\n        'source': file_path,\n        'elements': []\n    }\n    \n    for element in elements:\n        output['elements'].append({\n            'type': type(element).__name__,\n            'text': element.text,\n            'metadata': {\n                'page': element.metadata.page_number,\n                'coordinates': element.metadata.coordinates.to_dict() if element.metadata.coordinates else None\n            }\n        })\n    \n    if output_path:\n        with open(output_path, 'w') as f:\n            json.dump(output, f, indent=2)\n    \n    return output\n```\n\n### Email Parser\n```python\nfrom unstructured.partition.email import partition_email\n\ndef parse_email(email_path):\n    \"\"\"Extract structured data from email.\"\"\"\n    \n    elements = partition_email(email_path)\n    \n    email_data = {\n        'subject': None,\n        'from': None,\n        'to': [],\n        'date': None,\n        'body': [],\n        'attachments': []\n    }\n    \n    for element in elements:\n        meta = element.metadata\n        \n        # Extract headers from metadata\n        if meta.subject:\n            email_data['subject'] = meta.subject\n        if meta.sent_from:\n            email_data['from'] = meta.sent_from\n        if meta.sent_to:\n            email_data['to'] = meta.sent_to\n        \n        # Body content\n        email_data['body'].append({\n            'type': type(element).__name__,\n            'text': element.text\n        })\n    \n    return email_data\n```\n\n## Examples\n\n### Example 1: Research Paper Extraction\n```python\nfrom unstructured.partition.pdf import partition_pdf\nfrom unstructured.chunking.title import chunk_by_title\n\ndef extract_paper(pdf_path):\n    \"\"\"Extract structured data from research paper.\"\"\"\n    \n    elements = partition_pdf(\n        filename=pdf_path,\n        strategy=\"hi_res\",\n        infer_table_structure=True,\n        include_page_breaks=True\n    )\n    \n    paper = {\n        'title': None,\n        'abstract': None,\n        'sections': [],\n        'tables': [],\n        'references': []\n    }\n    \n    # Find title (usually first Title element)\n    for element in elements:\n        if element.category == \"Title\" and not paper['title']:\n            paper['title'] = element.text\n            break\n    \n    # Extract tables\n    for element in elements:\n        if element.category == \"Table\":\n            paper['tables'].append({\n                'page': element.metadata.page_number,\n                'content': element.text,\n                'html': element.metadata.text_as_html if hasattr(element.metadata, 'text_as_html') else None\n            })\n    \n    # Chunk into sections\n    chunks = chunk_by_title(elements, max_characters=2000)\n    \n    current_section = None\n    for chunk in chunks:\n        if chunk.category == \"Title\":\n            paper['sections'].append({\n                'title': chunk.text,\n                'content': ''\n            })\n        elif paper['sections']:\n            paper['sections'][-1]['content'] += chunk.text + '\\n'\n    \n    return paper\n\npaper = extract_paper('research_paper.pdf')\nprint(f\"Title: {paper['title']}\")\nprint(f\"Tables: {len(paper['tables'])}\")\nprint(f\"Sections: {len(paper['sections'])}\")\n```\n\n### Example 2: Invoice Data Extraction\n```python\nfrom unstructured.partition.auto import partition\nimport re\n\ndef extract_invoice_data(file_path):\n    \"\"\"Extract key data from invoice.\"\"\"\n    \n    elements = partition(file_path, strategy=\"hi_res\")\n    \n    # Combine all text\n    full_text = '\\n'.join([e.text for e in elements])\n    \n    invoice = {\n        'invoice_number': None,\n        'date': None,\n        'total': None,\n        'vendor': None,\n        'line_items': [],\n        'tables': []\n    }\n    \n    # Extract patterns\n    inv_match = re.search(r'Invoice\\s*#?\\s*:?\\s*(\\w+[-\\w]*)', full_text, re.I)\n    if inv_match:\n        invoice['invoice_number'] = inv_match.group(1)\n    \n    date_match = re.search(r'Date\\s*:?\\s*(\\d{1,2}[-\u002F]\\d{1,2}[-\u002F]\\d{2,4})', full_text, re.I)\n    if date_match:\n        invoice['date'] = date_match.group(1)\n    \n    total_match = re.search(r'Total\\s*:?\\s*\\$?([\\d,]+\\.?\\d*)', full_text, re.I)\n    if total_match:\n        invoice['total'] = float(total_match.group(1).replace(',', ''))\n    \n    # Extract tables\n    for element in elements:\n        if element.category == \"Table\":\n            invoice['tables'].append(element.text)\n    \n    return invoice\n\ninvoice = extract_invoice_data('invoice.pdf')\nprint(f\"Invoice #: {invoice['invoice_number']}\")\nprint(f\"Total: ${invoice['total']}\")\n```\n\n### Example 3: Document Corpus Builder\n```python\nfrom unstructured.partition.auto import partition\nfrom unstructured.chunking.title import chunk_by_title\nfrom pathlib import Path\nimport json\n\ndef build_corpus(input_dir, output_path):\n    \"\"\"Build searchable corpus from document collection.\"\"\"\n    \n    input_path = Path(input_dir)\n    corpus = []\n    \n    # Support multiple formats\n    patterns = ['*.pdf', '*.docx', '*.html', '*.txt', '*.md']\n    files = []\n    for pattern in patterns:\n        files.extend(input_path.glob(pattern))\n    \n    for file in files:\n        print(f\"Processing: {file.name}\")\n        \n        try:\n            elements = partition(str(file))\n            chunks = chunk_by_title(elements, max_characters=1000)\n            \n            for i, chunk in enumerate(chunks):\n                corpus.append({\n                    'id': f\"{file.stem}_{i}\",\n                    'source': str(file),\n                    'type': type(chunk).__name__,\n                    'text': chunk.text,\n                    'page': chunk.metadata.page_number if chunk.metadata.page_number else None\n                })\n        \n        except Exception as e:\n            print(f\"  Error: {e}\")\n    \n    # Save corpus\n    with open(output_path, 'w') as f:\n        json.dump(corpus, f, indent=2)\n    \n    print(f\"Corpus built: {len(corpus)} chunks from {len(files)} files\")\n    return corpus\n\ncorpus = build_corpus('.\u002Fdocuments', 'corpus.json')\n```\n\n## Limitations\n\n- Complex layouts may need manual review\n- OCR quality depends on image quality\n- Large files may need chunking\n- Some proprietary formats not supported\n- API rate limits for cloud processing\n\n## Installation\n\n```bash\n# Basic installation\npip install unstructured\n\n# With all dependencies\npip install \"unstructured[all-docs]\"\n\n# For PDF processing\npip install \"unstructured[pdf]\"\n\n# For specific formats\npip install \"unstructured[docx,pptx,xlsx]\"\n```\n\n## Resources\n\n- [unstructured GitHub](https:\u002F\u002Fgithub.com\u002FUnstructured-IO\u002Funstructured)\n- [Documentation](https:\u002F\u002Funstructured-io.github.io\u002Funstructured\u002F)\n- [Unstructured API](https:\u002F\u002Funstructured.io\u002Fapi-key)\n","# Data Extractor Skill\n\n## Overview\n\nThis skill enables extraction of structured data from any document format using **unstructured** - a unified library for processing PDFs, Word docs, emails, HTML, and more. Get consistent, structured output regardless of input format.\n\n## How to Use\n\n1. Provide the document to process\n2. Optionally specify extraction options\n3. I'll extract structured elements with metadata\n\n**Example prompts:**\n- \"Extract all text and tables from this PDF\"\n- \"Parse this email and get the body, attachments, and metadata\"\n- \"Convert this HTML page to structured elements\"\n- \"Extract data from these mixed-format documents\"\n\n## Domain Knowledge\n\n### unstructured Fundamentals\n\n```python\nfrom unstructured.partition.auto import partition\n\n# Automatically detect and process any document\nelements = partition(\"document.pdf\")\n\n# Access extracted elements\nfor element in elements:\n    print(f\"Type: {type(element).__name__}\")\n    print(f\"Text: {element.text}\")\n    print(f\"Metadata: {element.metadata}\")\n```\n\n### Supported Formats\n\n| Format | Function | Notes |\n|--------|----------|-------|\n| PDF | `partition_pdf` | Native + scanned |\n| Word | `partition_docx` | Full structure |\n| PowerPoint | `partition_pptx` | Slides & notes |\n| Excel | `partition_xlsx` | Sheets & tables |\n| Email | `partition_email` | Body & attachments |\n| HTML | `partition_html` | Tags preserved |\n| Markdown | `partition_md` | Structure preserved |\n| Plain Text | `partition_text` | Basic parsing |\n| Images | `partition_image` | OCR extraction |\n\n### Element Types\n\n```python\nfrom unstructured.documents.elements import (\n    Title,\n    NarrativeText,\n    Text,\n    ListItem,\n    Table,\n    Image,\n    Header,\n    Footer,\n    PageBreak,\n    Address,\n    EmailAddress,\n)\n\n# Elements have consistent structure\nelement.text           # Raw text content\nelement.metadata       # Rich metadata\nelement.category       # Element type\nelement.id            # Unique identifier\n```\n\n### Auto Partition\n\n```python\nfrom unstructured.partition.auto import partition\n\n# Process any file type\nelements = partition(\n    filename=\"document.pdf\",\n    strategy=\"auto\",          # or \"fast\", \"hi_res\", \"ocr_only\"\n    include_metadata=True,\n    include_page_breaks=True,\n)\n\n# Filter by type\ntitles = [e for e in elements if isinstance(e, Title)]\ntables = [e for e in elements if isinstance(e, Table)]\n```\n\n### Format-Specific Partitioning\n\n```python\n# PDF with options\nfrom unstructured.partition.pdf import partition_pdf\n\nelements = partition_pdf(\n    filename=\"document.pdf\",\n    strategy=\"hi_res\",              # High quality extraction\n    infer_table_structure=True,     # Detect tables\n    include_page_breaks=True,\n    languages=[\"en\"],               # OCR language\n)\n\n# Word documents\nfrom unstructured.partition.docx import partition_docx\n\nelements = partition_docx(\n    filename=\"document.docx\",\n    include_metadata=True,\n)\n\n# HTML\nfrom unstructured.partition.html import partition_html\n\nelements = partition_html(\n    filename=\"page.html\",\n    include_metadata=True,\n)\n```\n\n### Working with Tables\n\n```python\nfrom unstructured.partition.auto import partition\n\nelements = partition(\"report.pdf\", infer_table_structure=True)\n\n# Extract tables\nfor element in elements:\n    if element.category == \"Table\":\n        print(\"Table found:\")\n        print(element.text)\n        \n        # Access structured table data\n        if hasattr(element, 'metadata') and element.metadata.text_as_html:\n            print(\"HTML:\", element.metadata.text_as_html)\n```\n\n### Metadata Access\n\n```python\nfrom unstructured.partition.auto import partition\n\nelements = partition(\"document.pdf\")\n\nfor element in elements:\n    meta = element.metadata\n    \n    # Common metadata fields\n    print(f\"Page: {meta.page_number}\")\n    print(f\"Filename: {meta.filename}\")\n    print(f\"Filetype: {meta.filetype}\")\n    print(f\"Coordinates: {meta.coordinates}\")\n    print(f\"Languages: {meta.languages}\")\n```\n\n### Chunking for AI\u002FRAG\n\n```python\nfrom unstructured.partition.auto import partition\nfrom unstructured.chunking.title import chunk_by_title\nfrom unstructured.chunking.basic import chunk_elements\n\n# Partition document\nelements = partition(\"document.pdf\")\n\n# Chunk by title (semantic chunks)\nchunks = chunk_by_title(\n    elements,\n    max_characters=1000,\n    combine_text_under_n_chars=200,\n)\n\n# Or basic chunking\nchunks = chunk_elements(\n    elements,\n    max_characters=500,\n    overlap=50,\n)\n\nfor chunk in chunks:\n    print(f\"Chunk ({len(chunk.text)} chars):\")\n    print(chunk.text[:100] + \"...\")\n```\n\n### Batch Processing\n\n```python\nfrom unstructured.partition.auto import partition\nfrom pathlib import Path\nfrom concurrent.futures import ThreadPoolExecutor\n\ndef process_document(file_path):\n    \"\"\"Process single document.\"\"\"\n    try:\n        elements = partition(str(file_path))\n        return {\n            'file': str(file_path),\n            'status': 'success',\n            'elements': len(elements),\n            'text': '\\n\\n'.join([e.text for e in elements])\n        }\n    except Exception as e:\n        return {\n            'file': str(file_path),\n            'status': 'error',\n            'error': str(e)\n        }\n\ndef batch_process(input_dir, max_workers=4):\n    \"\"\"Process all documents in directory.\"\"\"\n    input_path = Path(input_dir)\n    files = list(input_path.glob('*'))\n    \n    with ThreadPoolExecutor(max_workers=max_workers) as executor:\n        results = list(executor.map(process_document, files))\n    \n    return results\n```\n\n### Export Formats\n\n```python\nfrom unstructured.partition.auto import partition\nfrom unstructured.staging.base import elements_to_json, elements_to_dicts\n\nelements = partition(\"document.pdf\")\n\n# To JSON string\njson_str = elements_to_json(elements)\n\n# To list of dicts\ndicts = elements_to_dicts(elements)\n\n# To DataFrame\nimport pandas as pd\ndf = pd.DataFrame(dicts)\n```\n\n## Best Practices\n\n1. **Choose Strategy Wisely**: \"fast\" for speed, \"hi_res\" for accuracy\n2. **Enable Table Detection**: For documents with tables\n3. **Specify Language**: For better OCR on non-English docs\n4. **Chunk for RAG**: Use semantic chunking for AI applications\n5. **Handle Errors**: Some formats may fail gracefully\n\n## Common Patterns\n\n### Document to JSON\n```python\ndef document_to_json(file_path, output_path=None):\n    \"\"\"Convert document to structured JSON.\"\"\"\n    from unstructured.partition.auto import partition\n    from unstructured.staging.base import elements_to_json\n    import json\n    \n    elements = partition(file_path)\n    \n    # Create structured output\n    output = {\n        'source': file_path,\n        'elements': []\n    }\n    \n    for element in elements:\n        output['elements'].append({\n            'type': type(element).__name__,\n            'text': element.text,\n            'metadata': {\n                'page': element.metadata.page_number,\n                'coordinates': element.metadata.coordinates.to_dict() if element.metadata.coordinates else None\n            }\n        })\n    \n    if output_path:\n        with open(output_path, 'w') as f:\n            json.dump(output, f, indent=2)\n    \n    return output\n```\n\n### Email Parser\n```python\nfrom unstructured.partition.email import partition_email\n\ndef parse_email(email_path):\n    \"\"\"Extract structured data from email.\"\"\"\n    \n    elements = partition_email(email_path)\n    \n    email_data = {\n        'subject': None,\n        'from': None,\n        'to': [],\n        'date': None,\n        'body': [],\n        'attachments': []\n    }\n    \n    for element in elements:\n        meta = element.metadata\n        \n        # Extract headers from metadata\n        if meta.subject:\n            email_data['subject'] = meta.subject\n        if meta.sent_from:\n            email_data['from'] = meta.sent_from\n        if meta.sent_to:\n            email_data['to'] = meta.sent_to\n        \n        # Body content\n        email_data['body'].append({\n            'type': type(element).__name__,\n            'text': element.text\n        })\n    \n    return email_data\n```\n\n## Examples\n\n### Example 1: Research Paper Extraction\n```python\nfrom unstructured.partition.pdf import partition_pdf\nfrom unstructured.chunking.title import chunk_by_title\n\ndef extract_paper(pdf_path):\n    \"\"\"Extract structured data from research paper.\"\"\"\n    \n    elements = partition_pdf(\n        filename=pdf_path,\n        strategy=\"hi_res\",\n        infer_table_structure=True,\n        include_page_breaks=True\n    )\n    \n    paper = {\n        'title': None,\n        'abstract': None,\n        'sections': [],\n        'tables': [],\n        'references': []\n    }\n    \n    # Find title (usually first Title element)\n    for element in elements:\n        if element.category == \"Title\" and not paper['title']:\n            paper['title'] = element.text\n            break\n    \n    # Extract tables\n    for element in elements:\n        if element.category == \"Table\":\n            paper['tables'].append({\n                'page': element.metadata.page_number,\n                'content': element.text,\n                'html': element.metadata.text_as_html if hasattr(element.metadata, 'text_as_html') else None\n            })\n    \n    # Chunk into sections\n    chunks = chunk_by_title(elements, max_characters=2000)\n    \n    current_section = None\n    for chunk in chunks:\n        if chunk.category == \"Title\":\n            paper['sections'].append({\n                'title': chunk.text,\n                'content': ''\n            })\n        elif paper['sections']:\n            paper['sections'][-1]['content'] += chunk.text + '\\n'\n    \n    return paper\n\npaper = extract_paper('research_paper.pdf')\nprint(f\"Title: {paper['title']}\")\nprint(f\"Tables: {len(paper['tables'])}\")\nprint(f\"Sections: {len(paper['sections'])}\")\n```\n\n### Example 2: Invoice Data Extraction\n```python\nfrom unstructured.partition.auto import partition\nimport re\n\ndef extract_invoice_data(file_path):\n    \"\"\"Extract key data from invoice.\"\"\"\n    \n    elements = partition(file_path, strategy=\"hi_res\")\n    \n    # Combine all text\n    full_text = '\\n'.join([e.text for e in elements])\n    \n    invoice = {\n        'invoice_number': None,\n        'date': None,\n        'total': None,\n        'vendor': None,\n        'line_items': [],\n        'tables': []\n    }\n    \n    # Extract patterns\n    inv_match = re.search(r'Invoice\\s*#?\\s*:?\\s*(\\w+[-\\w]*)', full_text, re.I)\n    if inv_match:\n        invoice['invoice_number'] = inv_match.group(1)\n    \n    date_match = re.search(r'Date\\s*:?\\s*(\\d{1,2}[-\u002F]\\d{1,2}[-\u002F]\\d{2,4})', full_text, re.I)\n    if date_match:\n        invoice['date'] = date_match.group(1)\n    \n    total_match = re.search(r'Total\\s*:?\\s*\\$?([\\d,]+\\.?\\d*)', full_text, re.I)\n    if total_match:\n        invoice['total'] = float(total_match.group(1).replace(',', ''))\n    \n    # Extract tables\n    for element in elements:\n        if element.category == \"Table\":\n            invoice['tables'].append(element.text)\n    \n    return invoice\n\ninvoice = extract_invoice_data('invoice.pdf')\nprint(f\"Invoice #: {invoice['invoice_number']}\")\nprint(f\"Total: ${invoice['total']}\")\n```\n\n### Example 3: Document Corpus Builder\n```python\nfrom unstructured.partition.auto import partition\nfrom unstructured.chunking.title import chunk_by_title\nfrom pathlib import Path\nimport json\n\ndef build_corpus(input_dir, output_path):\n    \"\"\"Build searchable corpus from document collection.\"\"\"\n    \n    input_path = Path(input_dir)\n    corpus = []\n    \n    # Support multiple formats\n    patterns = ['*.pdf', '*.docx', '*.html', '*.txt', '*.md']\n    files = []\n    for pattern in patterns:\n        files.extend(input_path.glob(pattern))\n    \n    for file in files:\n        print(f\"Processing: {file.name}\")\n        \n        try:\n            elements = partition(str(file))\n            chunks = chunk_by_title(elements, max_characters=1000)\n            \n            for i, chunk in enumerate(chunks):\n                corpus.append({\n                    'id': f\"{file.stem}_{i}\",\n                    'source': str(file),\n                    'type': type(chunk).__name__,\n                    'text': chunk.text,\n                    'page': chunk.metadata.page_number if chunk.metadata.page_number else None\n                })\n        \n        except Exception as e:\n            print(f\"  Error: {e}\")\n    \n    # Save corpus\n    with open(output_path, 'w') as f:\n        json.dump(corpus, f, indent=2)\n    \n    print(f\"Corpus built: {len(corpus)} chunks from {len(files)} files\")\n    return corpus\n\ncorpus = build_corpus('.\u002Fdocuments', 'corpus.json')\n```\n\n## Limitations\n\n- Complex layouts may need manual review\n- OCR quality depends on image quality\n- Large files may need chunking\n- Some proprietary formats not supported\n- API rate limits for cloud processing\n\n## Installation\n\n```bash\n# Basic installation\npip install unstructured\n\n# With all dependencies\npip install \"unstructured[all-docs]\"\n\n# For PDF processing\npip install \"unstructured[pdf]\"\n\n# For specific formats\npip install \"unstructured[docx,pptx,xlsx]\"\n```\n\n## Resources\n\n- [unstructured GitHub](https:\u002F\u002Fgithub.com\u002FUnstructured-IO\u002Funstructured)\n- [Documentation](https:\u002F\u002Funstructured-io.github.io\u002Funstructured\u002F)\n- [Unstructured API](https:\u002F\u002Funstructured.io\u002Fapi-key)\n",{"name":5,"tags":43,"tools":45,"author":48,"models":49,"library":52,"version":55,"description":7},[44,21,19,30,36],"extraction",[28,46,47],"code_execution","file_operations","claude-office-skills",[50,51],"claude-sonnet-4","claude-opus-4",{"url":53,"name":21,"stars":54},"https:\u002F\u002Fgithub.com\u002FUnstructured-IO\u002Funstructured","14k","1.0","main","f4cb2d49f7667e79ef7804f50396d5aaffdf1f56","PDF及文件\u002Fdata-extractor",1,"https:\u002F\u002Fgithub.com\u002FKernel8901\u002Fai-agent-skills-classification","https:\u002F\u002Fgithub.com\u002FKernel8901","a little little little dobe in life but science geek","2026-04-05 16:43:56",{"source":8,"skillName":5,"commands":65,"prompt":75,"zipAvailable":76},[66,69,72],{"tool":67,"command":68},"npx","npx skills add Kernel8901\u002Fai-agent-skills-classification --skill data-extractor",{"tool":70,"command":71},"bunx","bunx skills add Kernel8901\u002Fai-agent-skills-classification --skill data-extractor",{"tool":73,"command":74},"pnpm","pnpm dlx skills add Kernel8901\u002Fai-agent-skills-classification --skill data-extractor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FKernel8901\u002Fai-agent-skills-classification\u002Fblob\u002Fmain\u002FPDF及文件\u002Fdata-extractor\u002FSKILL.md",true,[78],{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"_meta.json","REFERENCE","参考文档",288,"https:\u002F\u002Fgithub.com\u002FKernel8901\u002Fai-agent-skills-classification\u002Fblob\u002Fmain\u002FPDF及文件\u002Fdata-extractor\u002F_meta.json",[85,109,132,140,147,172],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":38},"01M6Q5R6WZ06RRB9RQTW54B34B","zyfai","Earn yield on any Ethereum wallet on Base, Arbitrum, and Plasma. Use when a user wants passive DeFi yield on their funds. Deploys a non-custodial subaccount (Safe) linked to their EOA, enables automated yield optimization, and lets them deposit\u002Fwithdraw anytime.","https:\u002F\u002Fgithub.com\u002FKernel8901\u002Fai-agent-skills-classification\u002Fblob\u002Fmain\u002F金融\u002Fzyfai-sdk\u002FSKILL.md",[],[87,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108],"safe","ethereum","defi","Optimization","user","use","Wallet","base","deposit","withdraw","yield","arbitrum","non-custodial","passive","defi yield","earn","yield optimization",{"skillNo":110,"name":111,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":38},"01M6Q5R337B5JSNER4P4YS03TN","zerion-api","https:\u002F\u002Fgithub.com\u002FKernel8901\u002Fai-agent-skills-classification\u002Fblob\u002Fmain\u002F金融\u002Fzerion-api\u002FSKILL.md",[],[115,116,117,118,119,120,121,94,122,98,123,124,125,126,127,128,129,130,131],"api","zerion api","zerion","MCP","mcp server","server","blockchain","transactions","crypto wallet","crypto","evm","solana","query","across","positions","token","prices",{"skillNo":133,"name":134,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":38},"01M6Q5QZFYTDAZMZ27BN5VZXAR","zerion-api-skill","https:\u002F\u002Fgithub.com\u002FKernel8901\u002Fai-agent-skills-classification\u002Fblob\u002Fmain\u002F金融\u002Fzerion-api-skill\u002FSKILL.md",[],[115,138,139,116,117,118,119,120,121,94,122,98,124,125,126,127,128,129,130,131],"api skill","zerion api skill",{"skillNo":141,"name":142,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":143,"categories":144,"keywords":145,"publishedAt":38},"01M6Q5QW17QW98RA3FE45E4RD8","zerion-api-mcp","https:\u002F\u002Fgithub.com\u002FKernel8901\u002Fai-agent-skills-classification\u002Fblob\u002Fmain\u002F金融\u002Fzerion-api-mcp\u002FSKILL.md",[],[118,115,146,116,117,119,120,94,122,98,123,124,125,126,127,128,129,130,131],"zerion api mcp",{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":38},"01M6Q5QQYZB7A501BDEQWKGSJT","yahoo-finance-forex","Fetches real-time FOREX news and market data from Yahoo Finance for major currency pairs (EUR\u002FUSD, GBP\u002FUSD, USD\u002FJPY, etc.). Analyzes sentiment and provides trading context.","https:\u002F\u002Fgithub.com\u002FKernel8901\u002Fai-agent-skills-classification\u002Fblob\u002Fmain\u002F金融\u002Fyahoo-finance-forex\u002FSKILL.md",[],[154,155,156,157,158,37,34,159,160,161,162,163,164,165,166,167,168,169,170,171],"finance","yahoo finance","forex","yahoo","yahoo finance forex","sentiment","real-time","python3","install","Market","usd","news","time","currency","gbp","pip","market data","for",{"skillNo":173,"name":174,"nameZh":6,"description":175,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":176,"categories":177,"keywords":178,"publishedAt":38},"01M6Q5QM6VS84WZVM7BKXXPF32","yahoo-finance","This skill should be used when the user asks to \"get stock prices\", \"check stock quotes\", \"look up earnings\", \"get financial data\", \"find trending stocks\", or needs stock market data from Yahoo Finance.","https:\u002F\u002Fgithub.com\u002FKernel8901\u002Fai-agent-skills-classification\u002Fblob\u002Fmain\u002F金融\u002Fyahoo-finance-cli\u002FSKILL.md",[],[154,155,157,179,180,181,182,183,184,163,185,186,187,188,189,190,191,192,131,170],"cli","homebrew","find","check","brew","up","local","get","stock","link","trending","sf","quotes","ln"]