[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FVR9J8MZZXYAFZ4QDF0KQ2":3,"skill-same:01M6FVR9J8MZZXYAFZ4QDF0KQ2":93},{"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":27,"publishedAt":48,"linkOnly":49,"markdownContent":50,"markdownBody":51,"frontMatter":52,"refName":66,"commitSha":67,"skillDirectory":68,"forksCount":69,"repositoryHtmlUrl":70,"repositoryHomepageUrl":6,"ownerHtmlUrl":71,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":72,"install":73,"resources":86},"01M6FVR9J8MZZXYAFZ4QDF0KQ2","data-extractor",null,"Extract structured data from any document format using unstructured - unified document processing","kbarbel640-del\u002Fskills","kbarbel640-del","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F255315490?v=4","01M6CJPPQGCCESXMG3K7BBGQ5J","01M6CJPPX2PB2BCZERFVM2C2B3",1,"MIT","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Flijie420461340\u002Fdata-extractor\u002FSKILL.md",[17,22],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000021","资料检索与研究","SCENARIO","使用场景",{"categoryNo":23,"categoryName":24,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47],"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":53,"tools":55,"author":58,"models":59,"library":62,"version":65,"description":7},[54,31,29,40,46],"extraction",[38,56,57],"code_execution","file_operations","claude-office-skills",[60,61],"claude-sonnet-4","claude-opus-4",{"url":63,"name":31,"stars":64},"https:\u002F\u002Fgithub.com\u002FUnstructured-IO\u002Funstructured","14k","1.0","main","e7e336ac628c3e3bd771aff1aaa469c93778f94a","skills\u002Flijie420461340\u002Fdata-extractor",0,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del","2026-08-23 22:39:37",{"source":8,"skillName":5,"commands":74,"prompt":84,"zipAvailable":85},[75,78,81],{"tool":76,"command":77},"npx","npx skills add kbarbel640-del\u002Fskills --skill data-extractor",{"tool":79,"command":80},"bunx","bunx skills add kbarbel640-del\u002Fskills --skill data-extractor",{"tool":82,"command":83},"pnpm","pnpm dlx skills add kbarbel640-del\u002Fskills --skill data-extractor","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Flijie420461340\u002Fdata-extractor\u002FSKILL.md",true,[87],{"path":88,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":91,"sourceHtmlUrl":92},"_meta.json","REFERENCE","参考文档",288,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Flijie420461340\u002Fdata-extractor\u002F_meta.json",[94,121,148,167,173,193],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":103,"publishedAt":48},"01M6G8J55967D6281ACMKAKTEQ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[100],{"categoryNo":101,"categoryName":102,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000036","内容创作者",[104,105,106,107,108,109,110,111,37,112,113,114,115,116,117,118,44,119,120],"crowd prompting","prompting","api","with","tokens","domain","world","prompts","instructions","text","tool","system","improve","productivity","marketplace","content","ai agents",{"skillNo":122,"name":123,"nameZh":6,"description":124,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":130,"publishedAt":48},"01M6G8J0PKPAYVET6BWE8W4C26","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[127],{"categoryNo":128,"categoryName":129,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发",[131,106,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,111,147],"dilemm ai","arena","analyze","browser","openclaw agent","create","automation","browser automation","bot","openclaw","design","strategy","headless","compete","submit","matchmaking","use",{"skillNo":149,"name":150,"nameZh":6,"description":151,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":152,"categories":153,"keywords":155,"publishedAt":48},"01M6G8HWAF3K9SW7NP3Z83CPJ6","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, or submitting paper reviews via API at http:\u002F\u002F150.158.152.82:8000.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Fweak-accept\u002FSKILL.md",[154],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[156,157,158,159,160,161,162,107,163,145,147,164,106,165,166],"arxiv paper reviews","reviews","arxiv","paper","crawler","papers","comments","fetch","read","http","via",{"skillNo":168,"name":150,"nameZh":6,"description":151,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":169,"categories":170,"keywords":172,"publishedAt":48},"01M6G8HQJ7N7WMY6YV7D7SSJ16","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[171],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},[159,158,157,156,166,161,162,107,160,145,147,163,164,106,165],{"skillNo":174,"name":175,"nameZh":6,"description":176,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":177,"categories":178,"keywords":179,"publishedAt":48},"01M6G8HM95Y64JNVFC2HN4E2BG","git-summary","Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzweack\u002Fgit-summary\u002FSKILL.md",[],[180,181,182,183,184,185,186,187,188,189,190,191,192],"git","summary","git summary","commits","repository","win32","status","linux","contributors","true","quick","get","branches",{"skillNo":194,"name":195,"nameZh":6,"description":196,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":197,"categories":198,"keywords":203,"publishedAt":48},"01M6G8HGEGF05CNEJCGVYFSC4R","agent-constitution","Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fztsalexey\u002Fagent-constitution\u002FSKILL.md",[199,200],{"categoryNo":128,"categoryName":129,"taxonomyType":20,"taxonomyTypeDesc":21},{"categoryNo":201,"categoryName":202,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000037","律师与法务",[204,205,206,207,107,208,209,66,210,164,211,212,213,214,215,44,216,217,47],"agent constitution","constitution","contracts","tree","query","base","log","check","Rules","projects","compliance","actions","state","governance"]