Skip to content

Conversation

@chanshing
Copy link
Member

Fixes bug where --csv-start-row was not respected when validating column indices via --csv-txyz-idxs. CSV files with metadata rows before the header (e.g., ActiGraph exports) would fail with "Column index X out of range" because the header was always read from row 0.

Changes

src/stepcount/utils.py

  • Add skiprows=csv_start_row when reading header for column index validation
  • Change skiprows from range(1, csv_start_row + 1) to csv_start_row for consistent semantics
  • Adjust nrows calculation to match new interpretation
  • Update docstrings: csv_start_row now clearly means "file row where header is located (0-indexed)"

Test

# Before: ValueError: Column index 3 out of range. CSV has 1 columns.
# After: Successfully processes file
stepcount data/WAVES_10006_RAW.csv.gz \
  --csv-start-row 10 \
  --csv-time-format "%m/%d/%Y %H:%M:%S.%f" \
  --csv-txyz-idxs "0,1,2,3"

…x validation

- Add skiprows=csv_start_row to header reading in read() when csv_txyz_idxs is specified
- Change skiprows from range(1, csv_start_row + 1) to csv_start_row for consistent semantics
- Adjust nrows calculation to match new interpretation (csv_start_row = header row, not first data row)
- Update docstrings to clarify csv_start_row means "file row where header is located"

Fixes bug where CSV files with metadata rows before header (e.g., ActiGraph exports)
would fail with "Column index X out of range" because header was read from row 0
instead of the specified csv_start_row.
@chanshing chanshing merged commit 2637f97 into main Jan 15, 2026
9 checks passed
@chanshing chanshing deleted the fix/csv-start-row-header-parsing branch January 15, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants