kantan.csv icon indicating copy to clipboard operation
kantan.csv copied to clipboard

Optional header field

Open mladendinev opened this issue 5 years ago • 2 comments

I'm processing a csv file with X number of columns which are not all mandatory i.e some of them are optional.

 csv.asCsvReader[Foo](rfc.withHeader)

  object Foo {
    implicit val FooDecoder: HeaderDecoder[Foo] =
      HeaderDecoder
        .decoder(
            "Mandatory1",
            "Mandatory2",
            "Optional1"
        )(Foo.apply)
  }

When Optional1 is missing from the csv header and there is no data respectively for that field, I'm getting "Missing header for Optional1". How can I prevent this error and handle it properly?

mladendinev avatar Jan 21 '20 14:01 mladendinev

I think, at the moment, you're kind of stuck. Those are two different formats, as far as kantan.csv is concerned. You can have optional data, but not optional headers.

nrinaudo avatar Jan 21 '20 16:01 nrinaudo

@nrinaudo Hi, we are considering using this lib at work and this would be a very useful feature, especially for historical data reprocessing any plan on implementing it ?

Jsebayhi avatar Jul 16 '20 11:07 Jsebayhi