[Haskell-cafe] Telling Cassava to ignore lines
andrew at operationaldynamics.com
Wed Sep 18 03:43:19 CEST 2013
I'm happily using Cassava to parse CSV, only to discover that
non-conforming lines in the input data are causing the parser to error
let e = decodeByName y' :: Either String (Header, Vector Person)
chugs along fine until line 461 of the input when
"parse error (endOfInput) at ..."
Ironically when my Person (ha) data type was all fields of :: Text it
just worked, but now that I've specified one or two of the fields as Int
or Float or whatever, it's mis-parsing.
Is there a way to tell it to just ignore lines that don't parse, rather
than it killing the whole run? Cassava understands skipping the *header*
line (and indeed using it to do the -by-name field mapping).
Otherwise the only thing I can see is going back to all the fields
being :: Text, and then running over that as an intermediate structure
and validating whether or not things parse to i.e. float.
More information about the Haskell-Cafe