RowView.byName

CsvResult!FieldView byName(scope const(char)[] name) const @safe pure nothrow @nogc

Lookup a field by column name using the attached header index.

Returns CsvResult!FieldView holding the field on success. Errors:

  • invalidDialect when no header index has been attached.
  • unknownColumn when the provided name is not present in the header.

Examples

import ddn.data.csv;
const text = "id,name\n1,Ada\n";
auto it = byRows(text);
auto header = it.front; it.popFront();
auto hidx = makeHeaderIndex(header);
auto row = it.front; row.attachHeader(&hidx);
auto nameField = row.byName("name");
assert(nameField.isOk && nameField.value.toString() == "Ada");