exstruct 0.3.2__tar.gz → 0.3.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {exstruct-0.3.2 → exstruct-0.3.5}/PKG-INFO +220 -47
  2. {exstruct-0.3.2 → exstruct-0.3.5}/README.md +219 -46
  3. {exstruct-0.3.2 → exstruct-0.3.5}/pyproject.toml +1 -1
  4. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/backends/base.py +3 -3
  5. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/cells.py +18 -5
  6. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/integrate.py +3 -0
  7. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/modeling.py +21 -3
  8. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/pipeline.py +130 -7
  9. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/engine.py +4 -1
  10. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/io/__init__.py +14 -6
  11. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/models/__init__.py +30 -12
  12. {exstruct-0.3.2 → exstruct-0.3.5}/LICENSE +0 -0
  13. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/__init__.py +0 -0
  14. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/cli/availability.py +0 -0
  15. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/cli/main.py +0 -0
  16. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/__init__.py +0 -0
  17. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/backends/__init__.py +0 -0
  18. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/backends/com_backend.py +0 -0
  19. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/backends/openpyxl_backend.py +0 -0
  20. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/charts.py +0 -0
  21. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/logging_utils.py +0 -0
  22. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/ranges.py +0 -0
  23. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/shapes.py +0 -0
  24. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/core/workbook.py +0 -0
  25. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/errors.py +0 -0
  26. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/io/serialize.py +0 -0
  27. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/models/maps.py +0 -0
  28. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/models/types.py +0 -0
  29. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/py.typed +0 -0
  30. {exstruct-0.3.2 → exstruct-0.3.5}/src/exstruct/render/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: exstruct
3
- Version: 0.3.2
3
+ Version: 0.3.5
4
4
  Summary: Excel to structured JSON (tables, shapes, charts) for LLM/RAG pipelines
5
5
  Keywords: excel,structure,data,exstruct
6
6
  Author: harumiWeb
@@ -57,7 +57,7 @@ Description-Content-Type: text/markdown
57
57
 
58
58
  [![PyPI version](https://badge.fury.io/py/exstruct.svg)](https://pypi.org/project/exstruct/) [![PyPI Downloads](https://static.pepy.tech/personalized-badge/exstruct?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/exstruct) ![Licence: BSD-3-Clause](https://img.shields.io/badge/license-BSD--3--Clause-blue?style=flat-square) [![pytest](https://github.com/harumiWeb/exstruct/actions/workflows/pytest.yml/badge.svg)](https://github.com/harumiWeb/exstruct/actions/workflows/pytest.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/e081cb4f634e4175b259eb7c34f54f60)](https://app.codacy.com/gh/harumiWeb/exstruct/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![codecov](https://codecov.io/gh/harumiWeb/exstruct/graph/badge.svg?token=2XI1O8TTA9)](https://codecov.io/gh/harumiWeb/exstruct)
59
59
 
60
- ![ExStruct Image](/docs/assets/icon.webp)
60
+ ![ExStruct Image](docs/assets/icon.webp)
61
61
 
62
62
  ExStruct reads Excel workbooks and outputs structured data (cells, table candidates, shapes, charts, smartart, merged cell ranges, print areas/views, auto page-break areas, hyperlinks) as JSON by default, with optional YAML/TOON formats. It targets both COM/Excel environments (rich extraction) and non-COM environments (cells + table candidates + print areas), with tunable detection heuristics and multiple output modes to fit LLM/RAG pipelines.
63
63
 
@@ -98,8 +98,8 @@ exstruct input.xlsx -o out.json --pretty # pretty JSON to a file
98
98
  exstruct input.xlsx --format yaml # YAML (needs pyyaml)
99
99
  exstruct input.xlsx --format toon # TOON (needs python-toon)
100
100
  exstruct input.xlsx --sheets-dir sheets/ # split per sheet in chosen format
101
- exstruct input.xlsx --print-areas-dir areas/ # split per print area (if any)
102
101
  exstruct input.xlsx --auto-page-breaks-dir auto_areas/ # COM only; option appears when available
102
+ exstruct input.xlsx --print-areas-dir areas/ # split per print area (if any)
103
103
  exstruct input.xlsx --mode light # cells + table candidates only
104
104
  exstruct input.xlsx --pdf --image # PDF and PNGs (Excel required)
105
105
  ```
@@ -147,9 +147,9 @@ engine = ExStructEngine(
147
147
  ),
148
148
  )
149
149
  wb2 = engine.extract("input.xlsx")
150
- engine.export(wb2, Path("out_filtered.json")) # drops shapes via filters
150
+ engine.export(wb2, Path("out_filtered.json"))
151
151
 
152
- # Enable hyperlinks in other modes
152
+ # Enable hyperlinks in standard mode
153
153
  engine_links = ExStructEngine(options=StructOptions(mode="standard", include_cell_links=True))
154
154
  with_links = engine_links.extract("input.xlsx")
155
155
 
@@ -216,7 +216,7 @@ To show how well exstruct can structure Excel, we parse a workbook that combines
216
216
  - Flowchart built only with shapes
217
217
 
218
218
  (Screenshot below is the actual sample Excel sheet)
219
- ![Sample Excel](/docs/assets/demo_sheet.png)
219
+ ![Sample Excel](docs/assets/demo_sheet.png)
220
220
  Sample workbook: `sample/sample.xlsx`
221
221
 
222
222
  ### 1. Input: Excel Sheet Overview
@@ -391,11 +391,12 @@ flowchart TD
391
391
  ```
392
392
  ````
393
393
 
394
+
394
395
  ## Example 2: General Application Form
395
396
 
396
397
  ### Excel Sheet
397
398
 
398
- ![General Application Form Excel](/docs/assets/demo_form.en.png)
399
+ ![General Application Form Excel](docs/assets/demo_form_en.png)
399
400
 
400
401
  ### ExStruct JSON
401
402
 
@@ -403,73 +404,240 @@ flowchart TD
403
404
 
404
405
  ```json
405
406
  {
406
- "book_name": "ja_form.xlsx",
407
+ "book_name": "en_sf425.xlsx",
407
408
  "sheets": {
408
- "Sheet1": {
409
+ "FFR": {
409
410
  "rows": [
410
- { "r": 1, "c": { "0": "??????????????" } },
411
+ { "r": 1, "c": { "0": "FEDERAL FINANCIAL REPORT" } },
412
+ { "r": 3, "c": { "0": "(Follow form instructions)" } },
411
413
  {
412
- "r": 3,
413
- "c": { "0": "???", "7": " ???????????????" }
414
+ "r": 4,
415
+ "c": {
416
+ "0": "1. Federal Agency and Organizational Element",
417
+ "5": "2. Federal Grant or Other Identifying Number Assigned by Federal Agency",
418
+ "20": "Page",
419
+ "23": " of"
420
+ }
414
421
  },
415
- { "r": 4, "c": { "1": "X???" } },
416
422
  ...
417
423
  ],
418
- "table_candidates": ["B25:C26", "C37:D50"],
419
- "merged_cells": [
424
+ "shapes": [
420
425
  {
421
- "r1": 55,
422
- "c1": 5,
423
- "r2": 55,
424
- "c2": 10,
425
- "v": "?????????????????????????????"
426
- },
427
- { "r1": 54, "c1": 8, "r2": 54, "c2": 10 },
428
- { "r1": 51, "c1": 5, "r2": 52, "c2": 6, "v": "????" },
429
- ...
430
- ]
426
+ "id": 1,
427
+ "text": "Not Required by EPA",
428
+ "l": 575,
429
+ "t": 396,
430
+ "kind": "shape",
431
+ "type": "AutoShape-Rectangle"
432
+ }
433
+ ],
434
+ "print_areas": [{ "r1": 1, "c1": 0, "r2": 66, "c2": 23 }],
435
+ "merged_cells": {
436
+ "schema": ["r1", "c1", "r2", "c2", "v"],
437
+ "items": [
438
+ [34, 15, 34, 23, " "],
439
+ [56, 10, 57, 17, "Federal Share Calculation"],
440
+ [18, 10, 18, 23, " "],
441
+ [15, 0, 15, 1, " "],
442
+ ...
443
+ ]
444
+ }
431
445
  }
432
446
  }
433
447
  }
448
+
449
+ ```
450
+
451
+ ### Migration note (v0.3.5): merged_cells format change
452
+
453
+ `merged_cells` changed from a list of objects to a schema/items structure in v0.3.5 (breaking change for JSON consumers).
454
+
455
+ Old format (<= v0.3.2):
456
+
457
+ ```json
458
+ "merged_cells": [
459
+ { "r1": 34, "c1": 15, "r2": 34, "c2": 23, "v": " " },
460
+ { "r1": 56, "c1": 10, "r2": 57, "c2": 17, "v": "Federal Share Calculation" }
461
+ ]
462
+ ```
463
+
464
+ New format (v0.3.5+):
465
+
466
+ ```json
467
+ "merged_cells": {
468
+ "schema": ["r1", "c1", "r2", "c2", "v"],
469
+ "items": [
470
+ [34, 15, 34, 23, " "],
471
+ [56, 10, 57, 17, "Federal Share Calculation"]
472
+ ]
473
+ }
474
+ ```
475
+
476
+ Migration example (support both during transition):
477
+
478
+ ```python
479
+ def normalize_merged_cells(raw):
480
+ schema = ["r1", "c1", "r2", "c2", "v"]
481
+ if isinstance(raw, list):
482
+ items = [[d.get(k, " ") for k in schema] for d in raw]
483
+ return {"schema": schema, "items": items}
484
+ if isinstance(raw, dict) and "schema" in raw and "items" in raw:
485
+ return raw
486
+ return None
434
487
  ```
435
488
 
436
489
  ### LLM reconstruction example
437
490
 
438
491
  ```md
439
- # ??????????????
492
+ <!-- This is a structured interpretation, not an official reproduction. -->
493
+
494
+ # **Federal Financial Report (FFR)**
495
+
496
+ _(Follow form instructions)_
497
+
498
+ ---
499
+
500
+ ## **1. Federal Agency and Organizational Element**
501
+
502
+ **United States Environmental Protection Agency**
503
+
504
+ ## **2. Federal Grant or Other Identifying Number Assigned by Federal Agency**
505
+
506
+ **Page 1 of pages**
507
+
508
+ ---
509
+
510
+ ## **3. Recipient Organization**
511
+
512
+ _(Name and complete address including Zip code)_
513
+
514
+ ---
515
+
516
+ ## **4. Recipient Identifiers**
517
+
518
+ - **4a. DUNS Number**
519
+ - **4b. EIN**
520
+ - **5. Recipient Account Number or Identifying Number**
521
+ _(To report multiple grants, use FFR Attachment)_
522
+ - **6. Report Type**
523
+ - □ Quarterly
524
+ - □ Semi-Annual
525
+ - □ Annual
526
+ - □ Final
527
+ - **7. Basis of Accounting**
528
+ - □ Cash
529
+ - □ Accrual
530
+
531
+ ---
532
+
533
+ ## **8. Project/Grant Period**
534
+
535
+ - **From:** (Month, Day, Year)
536
+ - **To:** (Month, Day, Year)
537
+
538
+ ## **9. Reporting Period End Date**
539
+
540
+ (Month, Day, Year)
541
+
542
+ ---
543
+
544
+ # **10. Transactions**
545
+
546
+ _(Use lines a–c for single or multiple grant reporting)_
547
+
548
+ ### **Federal Cash**
549
+
550
+ _(To report multiple grants, also use FFR Attachment)_
551
+
552
+ - **a. Cash Receipts**
553
+ - **b. Cash Disbursements**
554
+ - **c. Cash on Hand** (line a minus b)
555
+
556
+ _(Use lines d–o for single grant reporting)_
557
+
558
+ ### **Federal Expenditures and Unobligated Balance**
559
+
560
+ - **d. Total Federal funds authorized**
561
+ - **e. Federal share of expenditures**
562
+ - **f. Federal share of unliquidated obligations** — 0
563
+ - **g. Total Federal share** (sum of lines e and f) — 0
564
+ - **h. Unobligated balance of Federal funds** (line d minus g) — 0
565
+
566
+ ### **Recipient Share**
567
+
568
+ - **i. Total recipient share required**
569
+ - **j. Recipient share of expenditures**
570
+ - **k. Remaining recipient share to be provided** (line i minus j) — 0
571
+
572
+ ### **Program Income**
573
+
574
+ - **l. Total Federal program income earned**
575
+ - **m. Program income expended (deduction alternative)**
576
+ - **n. Program income expended (addition alternative)**
577
+ - **o. Unexpended program income** (line l minus line m or line n)
440
578
 
441
- ????????????????????????
442
- X ??
579
+ ---
580
+
581
+ # **11. Indirect Expense**
582
+
583
+ | Type | Rate | Period From | Period To | Base | Amount Charged | Federal Share |
584
+ | -------------- | ---- | ----------- | --------- | ---- | -------------- | ------------- |
585
+ | | | | | | | |
586
+ | **g. Totals:** | | | | 0 | 0 | 0 |
587
+
588
+ ---
589
+
590
+ # **12. Remarks**
591
+
592
+ Attach any explanations deemed necessary or information required by the Federal sponsoring agency in compliance with governing legislation.
593
+
594
+ ---
595
+
596
+ # **13. Certification**
597
+
598
+ By signing this report, I certify that it is true, complete, and accurate to the best of my knowledge.
599
+ I am aware that any false, fictitious, or fraudulent information may subject me to criminal, civil, or administrative penalties.
600
+ _(U.S. Code, Title 18, Section 1001)_
443
601
 
444
- ?????????????????????????????????????????
602
+ - **a. Typed or Printed Name and Title of Authorized Certifying Official**
603
+ - **b. Signature of Authorized Certifying Official**
604
+ - **c. Telephone** (Area code, number, extension)
605
+ - **d. Email address**
606
+ - **e. Date Report Submitted** (Month, Day, Year)
445
607
 
446
608
  ---
447
609
 
448
- ## ??????
610
+ # **14. Agency Use Only**
449
611
 
450
- | ?? | ?? |
451
- | ------ | -------------- |
452
- | ???? | |
453
- | ????? | |
454
- | ?????? | |
455
- | ???? | |
456
- | ???? | ?????????????? |
457
- | ?? | |
458
- | ??? | |
612
+ **Federal Share Calculation**
459
613
 
460
614
  ---
461
615
 
462
- ## ?????????????
616
+ ### **Standard Form 425**
463
617
 
464
- | ?? | ?? |
465
- | ----------- | ----- |
466
- | ??????????? | |
467
- | ??? | |
468
- | ???????? | ????? |
618
+ **OMB Approval Number:** 0348-0061
619
+ **Expiration Date:** 02/28/2015
469
620
 
470
- **???????????????????????????????????????**
621
+ ---
622
+
623
+ # **Paperwork Burden Statement**
624
+
625
+ According to the Paperwork Reduction Act, as amended, no persons are required to respond to a collection of information unless it displays a valid OMB Control Number.
626
+ The valid OMB control number for this information collection is **0348-0061**.
627
+
628
+ Public reporting burden for this collection of information is estimated to average **1.5 hours per response**, including time for reviewing instructions, searching existing data sources, gathering and maintaining the data needed, and completing and reviewing the collection of information.
629
+
630
+ Send comments regarding the burden estimate or any other aspect of this collection of information, including suggestions for reducing this burden, to:
631
+
632
+ **Office of Management and Budget**
633
+ Paperwork Reduction Project (0348-0060)
634
+ Washington, DC 20503
471
635
 
472
- ...
636
+ ---
637
+
638
+ ### **Shape in Original Document**
639
+
640
+ - _Not Required by EPA_
473
641
  ```
474
642
 
475
643
  From this we can see:
@@ -519,6 +687,11 @@ This project is suitable for teams that:
519
687
  - Use CLI `--auto-page-breaks-dir` (COM only), `DestinationOptions.auto_page_breaks_dir` (preferred), or `export_auto_page_breaks(...)` to write per-auto-page-break files; the API raises `ValueError` if no auto page breaks exist.
520
688
  - `PrintAreaView` includes rows and table candidates inside the area, plus shapes/charts that overlap the area (size-less shapes are treated as points). `normalize=True` rebases row/col indices to the area origin.
521
689
 
690
+ ## Documentation build
691
+
692
+ - Update generated model docs before building the site: `python scripts/gen_model_docs.py`.
693
+ - Build locally with mkdocs + mkdocstrings (dev deps required): `uv run mkdocs serve` or `uv run mkdocs build`.
694
+
522
695
  ## Architecture
523
696
 
524
697
  ExStruct uses a pipeline-based architecture that separates