View source code
Display the source code in std/csv.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Enum std.csv.Malformed

Determines the behavior for when an error is detected.

enum Malformed : int { ... }

Disabling exception will follow these rules:

  • A quote can appear in a field if the field was not quoted.
  • If in a quoted field any quote by itself, not at the end of a field, will end processing for that field.
  • The field is ended when there is no input, even if the quote was not closed.
  • If the given header does not match the order in the input, the content will return as it is found in the input.
  • If the given header contains columns not found in the input they will be ignored.

Enum members

NameDescription
ignore No exceptions are thrown due to incorrect CSV.
throwException Use exceptions when input has incorrect CSV.

Example

import std.algorithm.comparison : equal;
import std.algorithm.searching : count;
import std.exception : assertThrown;

string text = "a,b,c\nHello,65,\"2.5";
assertThrown!IncompleteCellException(text.csvReader.count);

// ignore the exceptions and try to handle invalid CSV
auto firstLine = text.csvReader!(string, Malformed.ignore)(null).front;
assert(firstLine.equal(["Hello", "65", "2.5"]));

Authors

Jesse Phillips

License

Boost License 1.0.