Styxis
Company
Knowledge

fast-csv headers: distinguishing field selection from renaming

Explain field selection separately from output-title changes so different teams do not assign different meanings to the same headers option.

fast-csv headers: distinguishing field selection from renaming

A CSV's first line showing the desired titles does not establish that original object values moved into those columns. The export contract depends on whether a headers list selects keys or renames their display labels. Inspect titles and actual row values together to avoid handing over a plausible-looking empty export. [1, 2, 3]

What the primary source establishes

A fast-csv usage report supplies headers that differ from the original object keys and gets an output with headings but no values. This report alone does not establish a library defect or confirm that the option supports renaming. [1]

The handover decision

The export owner should define a mapping from source keys to output titles, while the consumer accepts both the headers and required row values. Compare source_key, output_header, source_value, and exported_value rather than approving a file because its first line looks correct. [1, 3]

A reference defined before the output

The illustrative source has Name=John, mapped to output title Name1. John is the normal exported value. An empty string is the counterexample: changing the title without carrying the mapped value does not complete the export. The expectation comes from the explicit mapping, not from an assumption about the headers option. [1, 3]

The scoped Truthound check

Truthound Core 3.3.2 provides RowLevelValidator for a user-defined row_validator comparing prepared source_value and exported_value fields. Specify empty-string and null conditions separately; a NotNull check alone does not make them equivalent. The export code must perform the actual CSV-key mapping. [1, 2, 3]

Limits and alternative choices

An empty string differs from null and requires an explicit check or preprocessing policy. Map object keys before export or verify an explicit transformation path supported by the library. If headers selects actual keys that do not exist, empty output may be documented behavior rather than a bug. [1, 3]

Application conditions

Prepare an explicit source-key/output-title mapping and a row_validator that checks both null and empty strings.

Alternatives

Map object keys before export or verify an explicit transformation path supported by the library.

Limitations

  • An empty string differs from null and requires an explicit check or preprocessing policy.

Evidence

Event checked
Subject checked
Modified