feat: add comment character support to CSV parser - #1940
Conversation
|
Someone is attempting to deploy a commit to the xtylishanish-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
im-anishraj
left a comment
There was a problem hiding this comment.
@Pcmhacker-piro thanks for the detailed PR and test coverage. I added the GSSoC classification labels for this PR (gssoc, level:advanced, type:feature, type:testing, area:csv-parser, area:cpp-core, area:python-api).
I reviewed the diff and ran the local formatting checks. This is not merge-ready yet because CI lint is failing and I can reproduce the Python formatting issue locally:
python -m black --check arnio/io.py tests/test_csv.pytests/test_csv.py needs Black formatting; the long write_text(...) calls in the new comment tests are the immediate cause.
I also found one parser edge case to fix before this can merge: CsvReader::scan_schema() skips comments while looking for a header, but it does not handle EOF/all-comment files safely, and in the has_header=False branch it reads the first record without skipping comment lines first. That can make scan_csv(..., has_header=False, comment="#") infer schema from a comment row instead of the first data row. Please add focused tests for those scan paths and update scan_schema() to skip comment records consistently before choosing the header/first data row.
Please fix formatting, add the missing scan-schema edge tests, and rerun the targeted CSV tests/CI. I’ll re-review once those are updated.
da9d762 to
a6030f2
Compare
Adds a 'comment' parameter to read_csv, read_csv_chunked, and scan_csv that allows skipping comment lines (e.g. lines starting with '#') during CSV parsing. - Add std::optional<char> comment_char to CsvConfig - Add CsvParser::is_comment_line() to detect comment records - Skip comment lines in all code paths (header, skip_rows, data rows) - Expose via pybind11 bindings - Add Python validation and wiring - Add 18 comprehensive tests Closes im-anishraj#47
a6030f2 to
12e342c
Compare
|
@Pcmhacker-piro thanks for the quick update. The scan-schema edge cases are now covered in the PR diff, but CI still has a real lint/type-check blocker. GitHub Actions lint failure: The C++ binding exposes Local checks I ran on the latest commit: git diff --check origin/main...HEAD
python -m black --check arnio/io.py tests/test_csv.py
python -m ruff check arnio/io.py tests/test_csv.pyThose Python formatting/static checks passed locally. I did not approve/merge because CI is still failing and the mypy stub issue must be fixed first. |
|
@Pcmhacker-piro update: I see the follow-up stub commit on this branch, and the latest GitHub Actions lint job is now passing. I am waiting for the remaining CI jobs to finish before doing final review/approval. No extra action is needed from you right now unless one of the remaining jobs fails. |
|
I’ve fixed this issue so now you can assign me another one. |
im-anishraj
left a comment
There was a problem hiding this comment.
@Pcmhacker-piro I rechecked the latest commit after the stub fix. The previous requested changes are addressed: the stub now includes comment_char, the scan-schema comment edge cases are covered, and the GitHub Actions matrix is green apart from the external Vercel authorization status.
Approved from code review. I still cannot assign you another issue until this assignment is actually completed, which means PR #1940 is merged or the assignment is closed. Please wait for final maintainer-side Vercel/merge handling before requesting another issue.
|
Hi @Pcmhacker-piro, thanks for the solid work on comment-character support. I rechecked this after the latest CSV parser merge, and the PR is now showing Could you please update/rebase your branch against the latest |
|
@im-anishraj |
|
heyy @im-anishraj |
8e0487d to
d45352f
Compare
Adds a comment character parameter to skip comment lines in CSV files. - Adds comment_char field to CsvConfig and CsvParser - Skips comment lines in read_csv, read_csv_chunked, and scan_csv - Adds is_comment_line() to CsvParser in C++ - Validates comment character in Python Closes im-anishraj#1940
d45352f to
ce1f958
Compare
im-anishraj
left a comment
There was a problem hiding this comment.
@Pcmhacker-piro thanks for pushing the conflict-resolution update. I rechecked the current head and this still cannot merge yet because a non-Vercel lint check is failing.
The current CI lint job says Black would reformat tests/test_csv.py near the end of the file, around the stream.read_sizes assertions. Please run Black locally and push the formatted result.
The test matrix is also reporting test_website_api_reference_mentions_public_exports because current main is missing rename_columns_matching from the website API reference. That appears to be maintainer-side API-doc drift rather than your comment-character change. Vercel is also external/auth-limited and not your blocker.
Once formatting is green again, I can re-review the earlier BOM/comment and public docstring blockers on this updated head.
…licts in arnio/io.py, tests/test_csv.py, and cpp/src/csv_reader.cpp
ce1f958 to
78a53e5
Compare
|
heyyy @im-anishraj |
|
@Pcmhacker-piro I rechecked the latest head after your conflict/lint cleanup. The non-Vercel checks are green now, so the Black formatting blocker from my last review is cleared. Vercel is still external/auth-limited and not your blocker. I am leaving this in the maintainer review queue to recheck the earlier functionality/docstring concerns on the updated head. |
|
heyy @im-anishraj Thanks for the recheck and update. I’ll wait for the maintainer review and address any further feedback if needed. |
|
@Pcmhacker-piro I rechecked the current PR state while you are waiting for maintainer review. GitHub now reports Please update/rebase the branch against the latest |
…cts in website/api.html - Accept main's version of cleaning table (includes find_fuzzy_duplicates) - Add comment=None parameter to read_csv, read_csv_chunked, scan_csv docs - Document comment parameter in function descriptions
|
Hi @im-anishraj, I’ve resolved the merge conflicts and updated the branch. Kindly re-review the PR. Thanks 🙌 |
|
@Pcmhacker-piro thanks for resolving the merge conflicts and updating the branch. I rechecked the current PR state: GitHub no longer reports I am moving this back from |
|
@Pcmhacker-piro, thank you for repeatedly keeping this branch current. I completed the maintainer re-review and the two earlier functional/documentation blockers still remain on the latest diff, so I am moving this to
The non-Vercel CI on the current head is green, but these correctness and public-documentation items must be fixed before approval. Vercel is not a blocker. |
Description
Adds
commentparameter support toread_csv(),read_csv_chunked(), andscan_csv(), allowing users to skip comment lines (e.g., lines starting with#) during CSV parsing.Fixes #47
Root Cause
CsvConfighad no option for specifying a comment character. Lines starting with comment markers (e.g.,#) were parsed as regular data rows, producing malformed output.Implementation
C++ Core (
cpp/)csv_reader.h: Addedstd::optional<char> comment_chartoCsvConfigandis_comment_line()method toCsvParsercsv_reader.cpp: Skip comment records at every stage — before header reading, during skip_rows, and in both data-reading passes. Works inCsvReader::read(),CsvReader::scan_schema(),CsvChunkReader::open(), andCsvChunkReader::read_one_data_row(). Comment detection checks the first non-whitespace character of each complete record, so#inside quoted fields is never treated as a comment.Python Bindings (
bindings/)comment_charproperty on_CsvConfigvia pybind11Python API (
arnio/io.py)_validate_comment_char()validation functioncomment: str | None = Noneparameter toread_csv(),read_csv_chunked(), andscan_csv()Tests (
tests/test_csv.py)18 new tests covering:
commentis not specified#,%)nrows,skiprows,has_header=Falsescan_csvandread_csv_chunkedcomment supportTesting