Skip to content

Support supplied headers for headerless NamedCSV input - #148

Open
GtechGovind wants to merge 1 commit into
swiftcsv:masterfrom
GtechGovind:fix/headerless-csv-input
Open

GtechGovind wants to merge 1 commit into
swiftcsv:masterfrom
GtechGovind:fix/headerless-csv-input

Conversation

@GtechGovind

Copy link
Copy Markdown

Fixes #121.

I added NamedCSV(string:header:) and NamedCSV(url:header:) for inputs without a header row. Supplied names map to every data row, including the first, without prepending synthetic CSV text or changing the public CSVView protocol.

Dictionary enumeration retains the first row too. Short rows receive empty values for missing columns; rows exceeding the supplied names throw a parse error. Existing header-present initializers keep their behavior. Delimiter guessing, UTF-8 BOM handling, optional columns and row limits work with the new initializers. Serialization includes the supplied header.

I added five regression tests covering first-row retention, columns, dictionary enumeration, serialization round trips, quoted/custom-delimiter input, BOMs, row limits, width errors, empty input and URL loading, plus usage documentation.

Validation:

  • Baseline: 42 tests passed.
  • Updated full SwiftPM suite: 47 tests passed.
  • swift build passed.
  • macOS Xcode build passed using a command-only deployment target of 12.0 for the installed SDK; project support settings are unchanged.
  • git diff --check passed.
  • SwiftLint ran on touched Swift files and reported existing style warnings; it was not a clean lint run.

Remote CI and other Apple-platform builds remain to be verified.

@GtechGovind
GtechGovind marked this pull request as ready for review October 17, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSV file without header row

1 participant