Comment Line #-Prefix Skipper

Remove physical lines starting with # outside quoted CSV fields, preserving such lines inside multiline fields; # comments are an explicit non-RFC extension.

Description

Hash-prefixed comments are a deliberate CSV extension.

Hash-prefixed comments are a deliberate CSV extension. A hash-prefixed physical line inside a quoted multiline cell belongs to data rather than a comment.1

Remove physical lines starting with # outside quoted CSV fields, preserving such lines inside multiline fields; # comments are an explicit non-RFC extension.

When to use Comment Line #-Prefix Skipper

Use this for the following task: Remove physical lines starting with # outside quoted CSV fields, preserving such lines inside multiline fields; # comments are an explicit non-RFC extension.

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 Comment Line #-Prefix Skipper 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 csv, removedLineCount. 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

Track field/quote state across physical lines, including doubled quotes. Remove exact leading-# lines only outside quoted fields, preserve other raw text and validate the remaining CSV.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.

remove line starting # only when parser state is outside a quoted cell

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

Output fieldMeaningValue type
csvCSV textstring
removedLineCountRemoved line countinteger
json
{
  "input": {
    "csv": "# metadata\na,b\n\"first\n#inside\",c\n# final\n",
    "delimiter": ","
  },
  "output": {
    "csv": "a,b\n\"first\n#inside\",c\n",
    "removedLineCount": 2
  }
}

Limitations and assumptions

Indented hashes are not comments. RFC 4180 does not define comments, so enable this policy only for sources that use it.

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 Quoted Multiline Safe Splitter for this operation: Split CSV into raw record fragments without outer record endings, preserving quote spelling, embedded line endings, blank records, and escaped quote pairs. For a complementary task, use 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.

Further background: Format and language reference: Comment Line #-Prefix Skipper.

References

  1. Format and language reference: Comment Line #-Prefix Skipper — RFC Editor

  2. Comment Line #-Prefix Skipper — tool.io

Similar or alternative tools

  • Quoted Multiline Safe Splitter

    Split CSV into raw record fragments without outer record endings, preserving quote spelling, embedded line endings, blank records, and escaped quote pairs.

  • CSV Row Counter

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

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