Spaces:
Sleeping
Sleeping
Download create_sample_pdf.py from Iamyash2004/fintech-rag-platform: direct link, hf CLI and curl.
- Browser
- Download file 4.05 kB
-
https://huggingface.co/spaces/Iamyash2004/fintech-rag-platform/resolve/main/create_sample_pdf.py
- Command line
-
hf download hf://spaces/Iamyash2004/fintech-rag-platform/create_sample_pdf.py
-
curl -L -o create_sample_pdf.py https://huggingface.co/spaces/Iamyash2004/fintech-rag-platform/resolve/main/create_sample_pdf.py
4.05 kB
| """ | |
| Script to generate a sample corporate 10-K financial filing PDF for testing and demonstration. | |
| """ | |
| import os | |
| import sys | |
| # Ensure UTF-8 output on Windows terminal | |
| if hasattr(sys.stdout, 'reconfigure'): | |
| sys.stdout.reconfigure(encoding='utf-8') | |
| import fitz # PyMuPDF | |
| from app.config import UPLOAD_DIR | |
| from app.services.parser import parse_pdf_file | |
| from app.services.vector_store import get_vector_store | |
| def create_sample_10k_pdf(): | |
| filename = "Acme_Corp_2023_10K.pdf" | |
| filepath = os.path.join(UPLOAD_DIR, filename) | |
| doc = fitz.open() | |
| # Page 1: Executive Summary & Financial Highlights | |
| page1 = doc.new_page() | |
| text_page1 = """ | |
| ACME INTERNATIONAL CORP. | |
| ANNUAL REPORT (FORM 10-K) FOR FISCAL YEAR ENDED DECEMBER 31, 2023 | |
| ITEM 7. MANAGEMENT'S DISCUSSION AND ANALYSIS OF FINANCIAL CONDITION | |
| EXECUTIVE FINANCIAL SUMMARY | |
| For fiscal year 2023, Acme International Corp reported total revenue of $1,250.0 Million, representing a 14.2% increase compared to $1,094.5 Million in fiscal year 2022. Net income for the year reached $177.5 Million, driven by strong growth in core software cloud subscription services and operational cost efficiencies. | |
| FINANCIAL CONSOLIDATED HIGHLIGHTS TABLE (in Millions of USD): | |
| Metric FY 2023 FY 2022 YoY Change (%) | |
| -------------------------------------------------------------- | |
| Total Revenue 1,250.0 1,094.5 +14.2% | |
| Gross Margin 787.5 678.6 +16.0% | |
| Operating Expenses 510.0 450.0 +13.3% | |
| Net Income 177.5 142.0 +25.0% | |
| Diluted EPS ($) 3.55 2.84 +25.0% | |
| * Note 1: FY 2022 financials include restated figures reflecting the adoption of revised revenue accounting standard ASC 606. | |
| * Note 2: Gross margin percentage expanded by 110 basis points to 63.0% in FY 2023. | |
| """ | |
| page1.insert_text((50, 50), text_page1, fontsize=10) | |
| # Page 2: Balance Sheet & Credit Liquidity Risk | |
| page2 = doc.new_page() | |
| text_page2 = """ | |
| ITEM 8. FINANCIAL STATEMENTS AND SUPPLEMENTARY DATA | |
| CONSOLIDATED BALANCE SHEET | |
| As of December 31, 2023 (in Millions of USD) | |
| ASSETS: | |
| Current Assets: | |
| Cash and Cash Equivalents $340.5 | |
| Accounts Receivable, net $215.0 | |
| Inventories $95.0 | |
| Prepaid Expenses and Other $40.0 | |
| Total Current Assets $690.5 | |
| Non-Current Assets: | |
| Property, Plant and Equipment, net $420.0 | |
| Goodwill and Intangibles $310.0 | |
| TOTAL ASSETS $1,420.5 | |
| LIABILITIES AND STOCKHOLDERS' EQUITY: | |
| Current Liabilities: | |
| Accounts Payable $145.0 | |
| Accrued Operational Liabilities $115.0 | |
| Short-Term Borrowings $65.0 | |
| Total Current Liabilities $325.0 | |
| Non-Current Liabilities: | |
| Long-Term Senior Notes (Debt) $380.0 | |
| Total Liabilities $705.0 | |
| Stockholders' Equity: | |
| Common Stock and Retained Earnings $715.5 | |
| TOTAL LIABILITIES AND EQUITY $1,420.5 | |
| CREDIT & RATIO ANALYSIS: | |
| - Current Ratio = Total Current Assets / Total Current Liabilities = $690.5M / $325.0M = 2.12x (Strong Liquidity Coverage). | |
| - Debt-to-Equity Ratio = Total Debt ($445.0M) / Stockholders' Equity ($715.5M) = 0.62x (Healthy Solvency Profile). | |
| * Note 3: Long-term senior notes carry a fixed interest rate of 4.5% maturing in 2028 with no immediate refinancing risk. | |
| """ | |
| page2.insert_text((50, 50), text_page2, fontsize=10) | |
| doc.save(filepath) | |
| doc.close() | |
| print(f"[SUCCESS] Created sample 10-K PDF at: {filepath}") | |
| # Index into vector store automatically | |
| parsed_doc = parse_pdf_file(filepath) | |
| vector_store = get_vector_store() | |
| chunks = vector_store.index_parsed_document(parsed_doc) | |
| print(f"[SUCCESS] Auto-indexed {chunks} vector chunks into ChromaDB vector store.") | |
| if __name__ == "__main__": | |
| create_sample_10k_pdf() | |