universal-data-cleaner 2.7.0__tar.gz → 2.8.0__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 (33) hide show
  1. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/PKG-INFO +16 -4
  2. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/README.md +13 -3
  3. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/pyproject.toml +5 -1
  4. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/__init__.py +7 -1
  5. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/__main__.py +52 -12
  6. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/_version.py +1 -1
  7. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/ingestion.py +412 -82
  8. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/reporting.py +49 -3
  9. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/universal_data_cleaner.egg-info/PKG-INFO +16 -4
  10. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/universal_data_cleaner.egg-info/SOURCES.txt +1 -0
  11. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/universal_data_cleaner.egg-info/requires.txt +3 -0
  12. universal_data_cleaner-2.8.0/tests/test_excel_ingestion.py +443 -0
  13. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/LICENSE +0 -0
  14. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/setup.cfg +0 -0
  15. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/_roles.py +0 -0
  16. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/artifacts.py +0 -0
  17. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/cleaner.py +0 -0
  18. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/config.py +0 -0
  19. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/contract.py +0 -0
  20. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/decisions.py +0 -0
  21. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/integration.py +0 -0
  22. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/ml_audit.py +0 -0
  23. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/profiling.py +0 -0
  24. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/py.typed +0 -0
  25. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/data_cleaner/validation.py +0 -0
  26. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/universal_data_cleaner.egg-info/dependency_links.txt +0 -0
  27. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/universal_data_cleaner.egg-info/entry_points.txt +0 -0
  28. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/src/universal_data_cleaner.egg-info/top_level.txt +0 -0
  29. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/tests/test_data_cleaner.py +0 -0
  30. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/tests/test_ingestion.py +0 -0
  31. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/tests/test_ml_audit.py +0 -0
  32. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/tests/test_reporting.py +0 -0
  33. {universal_data_cleaner-2.7.0 → universal_data_cleaner-2.8.0}/tests/test_validation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: universal-data-cleaner
3
- Version: 2.7.0
3
+ Version: 2.8.0
4
4
  Summary: Production-ready, scikit-learn-compatible data cleaning transformer for pandas.
5
5
  Author: Haseeb Khan
6
6
  License-Expression: MIT
@@ -30,6 +30,8 @@ Requires-Dist: pandas>=2.2
30
30
  Requires-Dist: numpy>=1.26
31
31
  Requires-Dist: scikit-learn>=1.4
32
32
  Requires-Dist: joblib>=1.3
33
+ Provides-Extra: excel
34
+ Requires-Dist: openpyxl>=3.1; extra == "excel"
33
35
  Dynamic: license-file
34
36
 
35
37
  # Universal Data Cleaner
@@ -58,7 +60,7 @@ The docs site is the central reference. This README is the short entry point.
58
60
  | [Leak-safe workflow](https://devlprkhan.github.io/universal-data-cleaner/leak-safe-workflow/) | The fit/transform contract and common mistakes |
59
61
  | [Cleaning data](https://devlprkhan.github.io/universal-data-cleaner/cleaning/) | Config, roles, imputation, outliers, datetimes |
60
62
  | [Contracts & drift](https://devlprkhan.github.io/universal-data-cleaner/contracts/) | `ColumnSpec`, `DataContract`, drift checks |
61
- | [Safe ingestion](https://devlprkhan.github.io/universal-data-cleaner/ingestion/) | Contract-driven CSV reads and ingestion reports |
63
+ | [Safe ingestion](https://devlprkhan.github.io/universal-data-cleaner/ingestion/) | Contract-driven CSV and Excel reads with ingestion reports |
62
64
  | [Batch reporting](https://devlprkhan.github.io/universal-data-cleaner/reporting/) | `CleanerReport` and the `data-cleaner audit` CLI |
63
65
  | [Validation, joins & dedup](https://devlprkhan.github.io/universal-data-cleaner/validation-joins/) | Expectations, join diagnostics, integrity, dedup |
64
66
  | [ML split audit](https://devlprkhan.github.io/universal-data-cleaner/ml-split-audit/) | Duplicate, group, temporal, and target leakage |
@@ -81,6 +83,16 @@ uv add universal-data-cleaner
81
83
  The distribution name is `universal-data-cleaner`; the import name is
82
84
  `data_cleaner`.
83
85
 
86
+ For Excel input, install the optional extra:
87
+
88
+ ```bash
89
+ pip install "universal-data-cleaner[excel]"
90
+ ```
91
+
92
+ ```bash
93
+ uv add "universal-data-cleaner[excel]"
94
+ ```
95
+
84
96
  ```python
85
97
  from data_cleaner import CleanerConfig, DataCleaner
86
98
  ```
@@ -134,8 +146,8 @@ for the full explanation.
134
146
  - boolean coercion and imputation
135
147
  - datetime parsing plus calendar feature extraction
136
148
  - optional missing-value indicators and constant-column dropping
137
- - safe CSV ingestion with contract-driven coercion, identifier protection, date
138
- and boolean guards, and an audit report
149
+ - safe CSV and Excel ingestion with contract-driven coercion, identifier
150
+ protection, date and boolean guards, and an audit report
139
151
  - `CleanerReport` combining profile, contract drift, validation, ingestion, and
140
152
  cleaner decisions, plus a `data-cleaner audit` CLI
141
153
  - declarative contracts with roles, allowed values, ranges, patterns, and uniqueness
@@ -24,7 +24,7 @@ The docs site is the central reference. This README is the short entry point.
24
24
  | [Leak-safe workflow](https://devlprkhan.github.io/universal-data-cleaner/leak-safe-workflow/) | The fit/transform contract and common mistakes |
25
25
  | [Cleaning data](https://devlprkhan.github.io/universal-data-cleaner/cleaning/) | Config, roles, imputation, outliers, datetimes |
26
26
  | [Contracts & drift](https://devlprkhan.github.io/universal-data-cleaner/contracts/) | `ColumnSpec`, `DataContract`, drift checks |
27
- | [Safe ingestion](https://devlprkhan.github.io/universal-data-cleaner/ingestion/) | Contract-driven CSV reads and ingestion reports |
27
+ | [Safe ingestion](https://devlprkhan.github.io/universal-data-cleaner/ingestion/) | Contract-driven CSV and Excel reads with ingestion reports |
28
28
  | [Batch reporting](https://devlprkhan.github.io/universal-data-cleaner/reporting/) | `CleanerReport` and the `data-cleaner audit` CLI |
29
29
  | [Validation, joins & dedup](https://devlprkhan.github.io/universal-data-cleaner/validation-joins/) | Expectations, join diagnostics, integrity, dedup |
30
30
  | [ML split audit](https://devlprkhan.github.io/universal-data-cleaner/ml-split-audit/) | Duplicate, group, temporal, and target leakage |
@@ -47,6 +47,16 @@ uv add universal-data-cleaner
47
47
  The distribution name is `universal-data-cleaner`; the import name is
48
48
  `data_cleaner`.
49
49
 
50
+ For Excel input, install the optional extra:
51
+
52
+ ```bash
53
+ pip install "universal-data-cleaner[excel]"
54
+ ```
55
+
56
+ ```bash
57
+ uv add "universal-data-cleaner[excel]"
58
+ ```
59
+
50
60
  ```python
51
61
  from data_cleaner import CleanerConfig, DataCleaner
52
62
  ```
@@ -100,8 +110,8 @@ for the full explanation.
100
110
  - boolean coercion and imputation
101
111
  - datetime parsing plus calendar feature extraction
102
112
  - optional missing-value indicators and constant-column dropping
103
- - safe CSV ingestion with contract-driven coercion, identifier protection, date
104
- and boolean guards, and an audit report
113
+ - safe CSV and Excel ingestion with contract-driven coercion, identifier
114
+ protection, date and boolean guards, and an audit report
105
115
  - `CleanerReport` combining profile, contract drift, validation, ingestion, and
106
116
  cleaner decisions, plus a `data-cleaner audit` CLI
107
117
  - declarative contracts with roles, allowed values, ranges, patterns, and uniqueness
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "universal-data-cleaner"
7
- version = "2.7.0"
7
+ version = "2.8.0"
8
8
  description = "Production-ready, scikit-learn-compatible data cleaning transformer for pandas."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -43,6 +43,9 @@ dependencies = [
43
43
  "joblib>=1.3",
44
44
  ]
45
45
 
46
+ [project.optional-dependencies]
47
+ excel = ["openpyxl>=3.1"]
48
+
46
49
  [project.urls]
47
50
  Homepage = "https://github.com/devlprkhan/universal-data-cleaner"
48
51
  Documentation = "https://devlprkhan.github.io/universal-data-cleaner/"
@@ -64,6 +67,7 @@ dev = [
64
67
  "mypy>=2.4.0",
65
68
  "nbclient>=0.11.0",
66
69
  "nbformat>=5.11.1",
70
+ "openpyxl>=3.1",
67
71
  "pandas-stubs>=2.3.3.260113",
68
72
  "pre-commit>=4.6.2",
69
73
  "pytest>=9.1.1",
@@ -22,7 +22,12 @@ from .cleaner import DataCleaner
22
22
  from .config import CleanerConfig
23
23
  from .contract import ColumnSpec, Contract, DataContract, DriftReport
24
24
  from .decisions import CleaningDecision
25
- from .ingestion import IngestionError, IngestionReport, read_csv_safe
25
+ from .ingestion import (
26
+ IngestionError,
27
+ IngestionReport,
28
+ read_csv_safe,
29
+ read_excel_safe,
30
+ )
26
31
  from .integration import (
27
32
  DeduplicationReport,
28
33
  JoinDiagnosis,
@@ -89,6 +94,7 @@ __all__ = [
89
94
  "not_null",
90
95
  "profile_dataframe",
91
96
  "read_csv_safe",
97
+ "read_excel_safe",
92
98
  "row_count_between",
93
99
  "unique",
94
100
  "validate",
@@ -4,14 +4,19 @@ from __future__ import annotations
4
4
 
5
5
  import argparse
6
6
  import sys
7
+ import zipfile
7
8
  from pathlib import Path
8
9
 
10
+ import pandas as pd
11
+
9
12
  from ._version import __version__
10
13
  from .cleaner import DataCleaner
11
14
  from .contract import DataContract
12
- from .ingestion import read_csv_safe
15
+ from .ingestion import IngestionReport, read_csv_safe, read_excel_safe
13
16
  from .reporting import CleanerReport
14
17
 
18
+ _EXCEL_SUFFIXES = {".xls", ".xlsb", ".xlsm", ".xlsx", ".ods"}
19
+
15
20
 
16
21
  def build_parser() -> argparse.ArgumentParser:
17
22
  """Build the ``python -m data_cleaner`` argument parser."""
@@ -28,13 +33,33 @@ def build_parser() -> argparse.ArgumentParser:
28
33
 
29
34
  audit = subparsers.add_parser(
30
35
  "audit",
31
- help="Audit a CSV batch and print a report.",
36
+ help="Audit a CSV or Excel batch and print a report.",
32
37
  description=(
33
- "Read a CSV safely, then report its profile, contract findings, "
34
- "and cleaner decisions."
38
+ "Read a CSV or Excel file safely, then report its profile, contract "
39
+ "findings, and cleaner decisions."
40
+ ),
41
+ )
42
+ audit.add_argument("path", type=Path, help="CSV or Excel file to audit.")
43
+ sheet = audit.add_mutually_exclusive_group()
44
+ sheet.add_argument(
45
+ "--sheet",
46
+ default=None,
47
+ metavar="NAME",
48
+ help=(
49
+ "Excel worksheet name (defaults to the first sheet); only valid for "
50
+ "Excel input."
51
+ ),
52
+ )
53
+ sheet.add_argument(
54
+ "--sheet-index",
55
+ type=int,
56
+ default=None,
57
+ metavar="N",
58
+ help=(
59
+ "Zero-based Excel worksheet index; only valid for Excel input and "
60
+ "mutually exclusive with --sheet."
35
61
  ),
36
62
  )
37
- audit.add_argument("csv", type=Path, help="CSV file to audit.")
38
63
  source = audit.add_mutually_exclusive_group()
39
64
  source.add_argument(
40
65
  "--contract",
@@ -80,6 +105,24 @@ def _load_contract(path: Path) -> DataContract:
80
105
  return DataContract.from_json(path.read_text(encoding="utf-8"))
81
106
 
82
107
 
108
+ def _read_input(
109
+ path: Path, contract: DataContract | None, sheet: str | int | None
110
+ ) -> tuple[pd.DataFrame, IngestionReport]:
111
+ """Read a CSV or Excel input and return its ingestion report."""
112
+ if path.suffix.lower() in _EXCEL_SUFFIXES:
113
+ frame, ingestion = read_excel_safe(
114
+ path,
115
+ contract=contract,
116
+ sheet_name=0 if sheet is None else sheet,
117
+ on_error="ignore",
118
+ )
119
+ return frame, ingestion
120
+ if sheet is not None:
121
+ raise ValueError("--sheet is only valid for Excel input")
122
+ frame, ingestion = read_csv_safe(path, contract=contract, on_error="ignore")
123
+ return frame, ingestion
124
+
125
+
83
126
  def _run_audit(args: argparse.Namespace) -> int:
84
127
  contract: DataContract | None = None
85
128
  cleaner: DataCleaner | None = None
@@ -89,12 +132,9 @@ def _run_audit(args: argparse.Namespace) -> int:
89
132
  cleaner = DataCleaner.load(args.cleaner)
90
133
  contract = cleaner.fitted_contract()
91
134
 
92
- frame, ingestion = read_csv_safe(
93
- args.csv,
94
- contract=contract,
95
- on_error="ignore",
96
- )
97
- dataset_name = args.name or args.csv.stem
135
+ sheet = args.sheet if args.sheet is not None else args.sheet_index
136
+ frame, ingestion = _read_input(args.path, contract, sheet)
137
+ dataset_name = args.name or args.path.stem
98
138
  if cleaner is not None:
99
139
  report = CleanerReport.from_cleaner(
100
140
  cleaner,
@@ -137,7 +177,7 @@ def main(argv: list[str] | None = None) -> int:
137
177
  if args.command == "audit":
138
178
  try:
139
179
  return _run_audit(args)
140
- except (OSError, ValueError, TypeError) as exc:
180
+ except (ImportError, OSError, TypeError, ValueError, zipfile.BadZipFile) as exc:
141
181
  print(f"error: {exc}", file=sys.stderr)
142
182
  return 2
143
183
  parser.print_help()
@@ -1,4 +1,4 @@
1
1
  """Single source of truth for the package version."""
2
2
 
3
- __version__ = "2.7.0"
3
+ __version__ = "2.8.0"
4
4
  _ARTIFACT_VERSION = 2