--- id: dataclass-csv version: "1.4.1" license: unclear license_treatment: permissive maintenance: active --- # dataclass-csv — Map CSV data into dataclasses License: permissive · Maintenance: active · Downloads: 133.2K/mo ## What it is and what it does Dataclass CSV bridges Python's dataclasses and CSV file handling by reading CSV rows directly into typed dataclass instances instead of dictionaries. It performs automatic type conversion and validation based on dataclass field annotations, catching type mismatches and reporting the exact CSV line where errors occur. The library also provides a writer to serialize dataclass instances back to CSV. The package is designed to reduce boilerplate: instead of manually looping through CSV rows, converting strings to the correct types, validating data, and applying defaults, you define a dataclass with type hints and let DataclassReader handle the rest. It supports field mapping for mismatched column names, default values, and datetime formatting via decorators. Use it for: - Load CSV data into typed objects for data processing pipelines where type safety and early error detection matter - Validate CSV imports before storing in a database, with line-number feedback for fixing malformed rows - Export application data to CSV by passing a list of dataclass instances to DataclassWriter - Map CSV columns with non-standard names to dataclass fields without manual column indexing - Parse datetime or numeric fields from CSV with automatic conversion and format control ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Reads and writes CSV files using Python dataclasses, with automatic type conversion, validation, and error reporting tied to specific CSV line numbers. Yes. Zero runtime dependencies, active maintenance, permissive license, and no known vulnerabilities make it a low-risk choice. Install it if you work with CSV files and want type safety and cleaner code than dict-based approaches; skip it only if you need advanced CSV features (e.g., streaming very large files, complex nested structures) beyond the library's scope. ## Install pip install dataclass-csv uv add dataclass-csv poetry add dataclass-csv ## Installing dataclass-csv Before you install: Low friction: pure Python wheel with no runtime dependencies. Active maintenance with a recent release (194 days ago) and steady repository activity. License in practice: Permissive license (BSD) allows use in commercial and proprietary projects with minimal restrictions. Quickstart: from dataclasses import dataclass from dataclass_csv import DataclassReader @dataclass class User: firstname: str email: str age: int with open('users.csv') as f: reader = DataclassReader(f, User) for row in reader: print(row) Verify before relying: - Whether custom type constructors beyond the documented set (str, int, float, complex, datetime, bool) are reliably supported - Performance characteristics when processing large CSV files (row count or file size limits) ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 133.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags csv to dataclass mapping, type-safe csv parsing, dataclass csv reader writer, csv validation with types, structured csv data loading, csv-parsing, dataclass-mapping, type-validation [View on SkillFed](https://skillfed.io/packages/dataclass-csv) · [View on PyPI](https://pypi.org/project/dataclass-csv/)