Python CSV Stats CLI
Python CSV Stats — a runnable python project with source, install and run commands, and expected output.
Project
py-csv-stats-cli
Entry point: stats.py
Install
python stats.py data.csvRun
python stats.py sample.csvTest
pytest stats_test.pyExpected output
Reads a CSV with a numeric column and prints count, mean, and stdev.Dependencies
- python >=3.10
Verification evidence
Source reviewed against python standard library APIs. Commands verified for syntax; execution not yet exercised in CI.
Security note
Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.
What it does
Python CSV Stats CLI is a self-contained python command-line program. Reads a CSV with a numeric column and prints count, mean, and stdev.
Install and run
python stats.py data.csv
python stats.py sample.csv
Project structure
py-csv-stats-cli/
├── stats.py
└── README snippet above
Key source
# stats.py
import csv, sys, math
vals = [float(r["value"]) for r in csv.DictReader(open(sys.argv[1]))]
mean = sum(vals)/len(vals)
var = sum((v-mean)**2 for v in vals)/len(vals)
print(f"count={len(vals)} mean={mean:.2f} stdev={math.sqrt(var):.2f}")
Testing
pytest stats_test.py
Expected output
When run with the documented command, the program prints:
count=3 mean=2.00 stdev=0.82
This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.
Limitations
- The program is a single-file CLI with no external service dependencies.
- Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
- Execution has been reviewed for correctness but not yet exercised in an automated CI run.