Line Count vs Record Count Reconciler

Compare physical CSV line count with logical record count, treating CRLF as one break and a terminal ending as no extra line; embedded quoted breaks explain the excess physical lines.

Description

Physical line count can exceed CSV record count because quoted cells contain line breaks.

Physical line count can exceed CSV record count because quoted cells contain line breaks. Reconciling both clarifies why newline-based row counts differ.1

Compare physical CSV line count with logical record count, treating CRLF as one break and a terminal ending as no extra line; embedded quoted breaks explain the excess physical lines.

When to use Line Count vs Record Count Reconciler

Use this for the following task: Compare physical CSV line count with logical record count, treating CRLF as one break and a terminal ending as no extra line; embedded quoted breaks explain the excess physical lines.

Prepare the CSV text, decoded cells or byte values requested below. Choose delimiter and header flags explicitly when those fields are present.

How to use Line Count vs Record Count Reconciler and understand its results

  1. Prepare the CSV text, decoded cells or byte values requested below. Choose delimiter and header flags explicitly when those fields are present.
  2. Enter csv, delimiter using the field table, then run the tool.
  3. Read physicalLineCount, recordCount, embeddedBreakCount. Interpret flags, units, ordering and placeholder values using the rules below.
  4. Review any reported issue or failed check, correct the supplied values when appropriate, and verify the result in its intended context.
Input fieldMeaningValue type and boundsRequirement
csvCSV textstring; maximum text length 100000Required
delimiterDelimiterstring; choose ",", ";", "\t"Required

Parse records and count CRLF or standalone CR/LF breaks. Empty text has zero physical lines; a terminal ending does not add a new line. Return both counts and their difference.2

Parse delimiters only outside quoted fields and decode doubled quotes. A quoted line break stays inside its cell; malformed quoting is returned as an input error.

embeddedBreakCount = physicalLineCount−recordCount

This summarizes the declared operation. Units, indexing, inclusivity and exceptional cases are explained in the surrounding text.

Output fieldMeaningValue type
physicalLineCountPhysical line countinteger
recordCountRecord countinteger
embeddedBreakCountEmbedded break countinteger
json
{
  "input": {
    "csv": "a,b\n\"x\ny\",z\n",
    "delimiter": ","
  },
  "output": {
    "physicalLineCount": 3,
    "recordCount": 2,
    "embeddedBreakCount": 1
  }
}

Limitations and assumptions

Blank records are counted. This requires valid CSV rather than treating every physical line as independent.

Where CSV is parsed, the shared parser accepts comma, semicolon or tab separators, doubled quotes and quoted line breaks, with CR/LF/CRLF record endings. Blank records remain records. CSV inputs are bounded to 100000 UTF-16 units and 10000 fields. Malformed requests produce input errors. A successfully evaluated request can still contain false flags, empty result lists or a result outside the supplied threshold; those outcomes have the meanings stated above.

Alternative or Complementary methods

Choose CSV Row Counter for this operation: Count CSV records including blank records and quoted multiline fields, with an explicit header flag; physical lines are not records. For a complementary task, use Multiline Quoted Cell Line Counter for this operation: Find decoded CSV cells containing CR or LF and report their one-based line counts, counting CRLF as one break; positions are zero-based record and column indices.

Further background: Format and language reference: Line Count vs Record Count Reconciler.

References

  1. Format and language reference: Line Count vs Record Count Reconciler — RFC Editor

  2. Line Count vs Record Count Reconciler — tool.io

Similar or alternative tools

  • CSV Row Counter

    Count CSV records including blank records and quoted multiline fields, with an explicit header flag; physical lines are not records.

  • Multiline Quoted Cell Line Counter

    Find decoded CSV cells containing CR or LF and report their one-based line counts, counting CRLF as one break; positions are zero-based record and column indices.

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