feat: harden CSV analysis parsing and schema inference#6
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe775e6d32
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if not v: | ||
| return None | ||
| try: | ||
| return float(v) |
There was a problem hiding this comment.
Reject non-finite floats during CSV numeric parsing
Parsing values with float(v) currently accepts tokens like NaN, inf, and -inf as numeric values, but those later cause statistics.pstdev to raise ValueError (e.g., "cannot convert NaN to integer ratio") when building numeric stats. This makes build_analysis_payload* fail for common CSVs that encode missing numeric values as NaN, breaking both CLI analyze and the /api/analyze UI flow instead of returning a summary.
Useful? React with 👍 / 👎.
Motivation
int,float,date,string) so generated prompts contain better numeric context.Description
_parse_csv_textthat usescsv.Snifferto auto-detect delimiters (,,;,\t,|) with a safe fallback to,and used it for both text and file-based ingestion inbitnet_tools/analysis.py._to_intand_to_iso_dateand expanded inference to emitint,float,date, orstringper column, and computestd(population std) along with existingcount/mean/min/q1/median/q3/maxstats.tests/test_analysis.py) to validate integer/date inference, presence ofstd, and semicolon-delimited CSV handling, and wired the CLI to use the improved parser (verified with an integration smoke run).Testing
python -m pytest -qwhich returned3 passed.python -m bitnet_tools.cli analyze /tmp/next.csv --question '요약' --out /tmp/next_payload.jsonand verified inferreddtypeswere{'id': 'int', 'value': 'int', 'dt': 'date'}.prompttemplate).Codex Task