A flexible CSV member reader that auto-detects name columns
Project description
members-reader
A lightweight Python library and CLI for reading member records from CSV files. Automatically detects first- and last-name columns so it works with your existing data without any configuration.
Features
- Zero dependencies — pure Python standard library
- Auto-detects name columns (
first_name,firstname,first, and theirlast_equivalents) - Library + CLI — use it in code or from the terminal
- Full type hints throughout
- Structured logging — integrate with your application's log config
Installation
pip install members-reader
Or install directly from GitHub:
pip install git+https://github.com/ajacobusa/members-reader.git
Quick Start
As a library
from members_reader import get_member_names, read_members
# Get a list of "First Last" strings
names = get_member_names("members.csv")
print(names) # ["Alice Smith", "Bob Jones", ...]
# Get all fields as a list of dicts
members = read_members("members.csv")
print(members[0]) # {"id": "1", "first_name": "Alice", "last_name": "Smith", "email": "..."}
As a CLI
# Print names (one per line)
members-reader members.csv
# Output as JSON
members-reader members.csv --format json
# Output all CSV fields
members-reader members.csv --all-fields
# Combine flags
members-reader members.csv --all-fields --format json
# Enable debug logging
members-reader members.csv --verbose
API Reference
read_members(csv_path) -> list[dict]
Reads every row from a CSV file and returns them as a list of dicts keyed by header name.
| Parameter | Type | Description |
|---|---|---|
csv_path |
str | Path |
Path to the CSV file |
Raises
FileNotFoundError— file does not existValueError— file has no header row
get_member_names(csv_path) -> list[str]
Returns a list of full names in "First Last" format.
| Parameter | Type | Description |
|---|---|---|
csv_path |
str | Path |
Path to the CSV file |
Raises
FileNotFoundError— file does not existValueError— cannot detect name columns
find_name_columns(fieldnames) -> tuple[str, str]
Given a list of CSV header names, returns the (first_col, last_col) pair.
Recognised aliases:
| Meaning | Accepted values |
|---|---|
| First name | first_name, firstname, first |
| Last name | last_name, lastname, last |
Raises
ValueError— a required column is missing
CSV Format
Any CSV with a recognised first- and last-name column works. Extra columns are ignored.
id,first_name,last_name,email,gender
1,Alice,Smith,alice@example.com,Female
2,Bob,Jones,bob@example.com,Male
Logging
members-reader uses Python's standard logging module under the members_reader namespace. Plug it into your application's log configuration:
import logging
logging.basicConfig(level=logging.DEBUG)
from members_reader import get_member_names
names = get_member_names("members.csv")
# DEBUG members_reader.reader: Opening members.csv
# INFO members_reader.reader: Read 500 member(s) from members.csv
Error Handling
from pathlib import Path
from members_reader import get_member_names
try:
names = get_member_names(Path("members.csv"))
except FileNotFoundError as e:
print(f"File missing: {e}")
except ValueError as e:
print(f"Bad CSV structure: {e}")
Development Setup
git clone https://github.com/ajacobusa/members-reader.git
cd members-reader
python -m venv venv
# Windows: .\venv\Scripts\activate
# macOS/Linux: source venv/bin/activate
pip install -e ".[dev]"
Run tests:
pytest # all tests
pytest tests/test_reader.py # single file
pytest --cov=members_reader # with coverage
Publishing a Release
- Bump
versioninpyproject.tomlandsrc/members_reader/__init__.py - Commit and push
- Create a tag:
git tag v0.2.0 && git push --tags - The CI workflow automatically builds and publishes to PyPI
Contributing
See CONTRIBUTING.md.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file members_reader-0.1.0.tar.gz.
File metadata
- Download URL: members_reader-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0c009ec03ab5fbd835a63a6b05e49fcf656ad60f45808fbba9bbe1eae0e3793
|
|
| MD5 |
a799a210b542b71e7eba441dc20b3aaf
|
|
| BLAKE2b-256 |
414a2f2804f64bb70662b7ac8725b87758e2eaa282d8be1abf97ab85f1237412
|
Provenance
The following attestation bundles were made for members_reader-0.1.0.tar.gz:
Publisher:
ci.yml on ajacobusa/members-reader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
members_reader-0.1.0.tar.gz -
Subject digest:
d0c009ec03ab5fbd835a63a6b05e49fcf656ad60f45808fbba9bbe1eae0e3793 - Sigstore transparency entry: 1430024244
- Sigstore integration time:
-
Permalink:
ajacobusa/members-reader@1645d91bfb05517d28a3d0616aae89a95bc14f40 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ajacobusa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@1645d91bfb05517d28a3d0616aae89a95bc14f40 -
Trigger Event:
push
-
Statement type:
File details
Details for the file members_reader-0.1.0-py3-none-any.whl.
File metadata
- Download URL: members_reader-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
989c33eae4973f57e82c90f38a54f59fed3edd39f20ec162eb2c29abcb079d97
|
|
| MD5 |
d163cd8b584c73867384f6a539d23c9d
|
|
| BLAKE2b-256 |
191517b80d978cdbb173e938505a7c7c73fa76f58e59de57e97b343ee681e7f5
|
Provenance
The following attestation bundles were made for members_reader-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on ajacobusa/members-reader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
members_reader-0.1.0-py3-none-any.whl -
Subject digest:
989c33eae4973f57e82c90f38a54f59fed3edd39f20ec162eb2c29abcb079d97 - Sigstore transparency entry: 1430024283
- Sigstore integration time:
-
Permalink:
ajacobusa/members-reader@1645d91bfb05517d28a3d0616aae89a95bc14f40 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ajacobusa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@1645d91bfb05517d28a3d0616aae89a95bc14f40 -
Trigger Event:
push
-
Statement type: