Header Offset Record Index

Map a zero-based data record index to a zero-based CSV record index by adding one when a header exists; record indices do not count embedded physical lines.

Description

A CSV header occupies a record before the data rows.

A CSV header occupies a record before the data rows. Converting between a data-only index and an all-record index requires that offset, while physical line numbers can differ when fields contain line breaks.1

Map a zero-based data record index to a zero-based CSV record index by adding one when a header exists; record indices do not count embedded physical lines.

When to use Header Offset Record Index

Use this tool to map a zero-based data record index to a zero-based CSV record index by adding one when a header exists; record indices do not count embedded physical lines.

Choose the original CSV text, decoded cell strings, byte values or counts requested by this tool. Use the stated delimiter, encoding, indexing and number/date convention.

How to use Header Offset Record Index and understand its results

  1. Choose the original CSV text, decoded cell strings, byte values or counts requested by this tool. Use the stated delimiter, encoding, indexing and number/date convention.
  2. Enter dataIndex, hasHeader using the field table and calculation rules, then run the tool.
  3. Read recordIndex. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
Input fieldMeaningValue type; see rules belowRequirement
dataIndexData indexinteger; minimum: 0; maximum: 9007199254740991Required
hasHeaderHas headerbooleanRequired

Enter a nonnegative safe integer dataIndex and the hasHeader flag. Both indices are zero-based. The tool adds one using exact integer arithmetic when a header is present and otherwise keeps the index unchanged. A result beyond the safe-integer range is rejected rather than rounded.

recordIndex = dataIndex + (hasHeader ? 1 : 0)

Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.

Output fieldMeaningValue type
recordIndexRecord indexinteger; minimum: 0; maximum: 9007199254740991
json
{
  "input": {
    "dataIndex": 4,
    "hasHeader": true
  },
  "output": {
    "recordIndex": 5
  }
}

Limitations and assumptions

It does not read CSV, check that the indexed record exists, or calculate a physical line number. Supply a data index rather than a one-based displayed row number, and account for any additional preamble records separately.

Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.

Alternative or Complementary methods

Use RFC 4180 Quoted Field Parser Check: Check RFC 4180 field quoting with explicit Unicode and CR/LF extensions; blank records are retained, and field-width consistency is checked separately. For a complementary task, use Field-With-Linebreaks Flagger: Find zero-based cell indices containing CR or LF characters, treating both individual line endings and CRLF as line-break presence.

References

  1. Header Offset Record Index — tool.io

Similar or alternative tools

  • RFC 4180 Quoted Field Parser Check

    Check RFC 4180 field quoting with explicit Unicode and CR/LF extensions; blank records are retained, and field-width consistency is checked separately.

  • Field-With-Linebreaks Flagger

    Find zero-based cell indices containing CR or LF characters, treating both individual line endings and CRLF as line-break presence.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies