-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_usage.py
More file actions
32 lines (21 loc) · 785 Bytes
/
Copy pathbasic_usage.py
File metadata and controls
32 lines (21 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Read a CSV with automatic detection, then inspect the read report.
Run from anywhere: python examples/basic_usage.py
"""
from pathlib import Path
import csvtriage as ct
DATA = Path(__file__).parent.parent / "test_data" / "messy_data.csv"
def main() -> None:
frame = ct.read(DATA)
print(f"Loaded {frame.shape[0]} rows x {frame.shape[1]} columns")
print(f"Columns: {frame.columns}")
print()
# The report tells you exactly how the file was read.
print(frame.report.explain())
print()
# Clean common messiness; the original frame is left untouched.
cleaned = frame.clean()
print(f"After cleaning: {cleaned.shape[0]} rows")
for repair in cleaned.report.repairs:
print(f" - {repair}")
if __name__ == "__main__":
main()