YAML guides

Export a delimited contact list as YAML records

·

A delimited contact list supplies field names once at the top. The YAML export repeats those names in each mapping so an individual record can stand on its own.

CSV to YAML Converter

Read a two-record export

Use id,name as the header, then 007,Ada and 008, on the next two lines. The output sequence has two mappings. The first id is the string "007". The second name is the empty string "". Removing the trailing comma in that second row leaves a missing field and triggers a width diagnostic.

RFC 4180 — CSV format and media typeYAML 1.2.2 specification

Keep a line break inside a field

Wrap a multi-line note in double quotes in the source file. The output can display a backslash escape for its line break inside the YAML string. Reading that string restores the line break in the cell.

RFC 4180 — CSV format and media type

Keep a CSV value that looks like YAML syntax

Convert this two-column CSV to YAML. A warehouse label can contain punctuation or a word that a YAML reader might otherwise interpret as a special value.

A label containing a hash and a boolean-like string
bin,label
007,#winter
008,false
  • When the YAML is parsed, #winter should be a label value and false should be a string of five letters. The bin identifiers retain their leading zeros. Check the parsed values in the receiving application before replacing the CSV.

Common questions

Why must headers be unique?

Every cell needs its own mapping key. Repeated headers would give several values the same key in one record.

Can I select semicolon or pipe as the delimiter?

Yes. Choose it explicitly when punctuation makes automatic detection ambiguous.

Sources

Put it into practice.

Related guides