Regular expressions and text guides

Why splitting CSV on commas breaks quoted fields

Use a CSV parser for commas, quotes and embedded newlines, then inspect row and column counts.

Nav Tools ·

One comma is not always a delimiter

A comma inside a quoted field is content. A simple split creates an extra column and can misalign every following field.

Use the example to verify that the note remains one field. It should produce two columns, not three.

name,note
Ada,"hello, world"

Quotes and newlines need state

A doubled quote represents a quote within a quoted field. A quoted field may also contain a physical line break.

Counting text lines is therefore not the same as counting CSV records. A parser tracks quote state across delimiters and line boundaries.

name,note
Ada,"said ""yes"""

Specify the dialect

Real files may use commas, tabs or semicolons and different header conventions. Confirm delimiter and header settings before interpreting a conversion.

Use CSV Formatter for inspection and CSV/TSV conversion for a known target. Changing a delimiter should preserve field values, not blindly replace punctuation inside them.

Check the imported table

Verify record count, column count and a field containing punctuation. Also inspect leading zeros and long identifiers after spreadsheet import.

A parser validates framing but does not establish the business meaning of each column. Apply type and required-field checks in the consuming pipeline.

References

← Regular expressions and text guides