web-csv-toolbox - v0.14.0
    Preparing search index...

    Interface TokenLocation

    Token location object.

    interface TokenLocation {
        end: Position;
        rowNumber: number;
        start: Position;
    }
    Index

    Properties

    Properties

    End location.

    rowNumber: number

    Row number in the CSV (includes header if present). Starts from 1.

    This represents the logical CSV row number, not the physical line number. A single CSV row may span multiple lines if fields contain newline characters within quotes.

    Important distinction:

    • line: Physical line number (incremented by \n characters)
    • rowNumber: Logical CSV row (incremented by record delimiters)

    The header row (if present) is counted as row 1. This corresponds to the physical row position in the file, making it easy to locate in editors.

    For physical line numbers, use start.line or end.line.

    Primary use case: Error reporting. This field allows errors to be reported with both physical position (line, column) and logical row context (rowNumber), making it easier for users to locate issues in their CSV data.

    name,description       <- rowNumber: 1 (header)
    Alice,"Lives in
    New York"              <- rowNumber: 2 (spans line 2-3)
    Bob,"Works"            <- rowNumber: 3 (line 4)
    
    • Header: rowNumber: 1
    • Alice's row: start.line: 2, end.line: 3, rowNumber: 2
    • Bob's row: start.line: 4, end.line: 4, rowNumber: 3
    try {
    await parseString(csv);
    } catch (error) {
    if (error instanceof ParseError) {
    console.error(`Error at row ${error.rowNumber}, line ${error.position?.line}`);
    }
    }
    start: Position

    Start location.