-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling of headers #16
Conversation
Header(firstRow) match { | ||
case Left(error) => Pull.raiseError[F](error) | ||
case Right(headers) if headers.length =!= firstRow.length => | ||
Pull.raiseError[F](new HeaderError("The count of headers must match the count of columns")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially add the sizes in the message, I think it can be useful when this happens, to debug
csv/src/fs2/data/csv/package.scala
Outdated
def attemptDecode[F[_], R](implicit F: Applicative[F], | ||
R: RowDecoder[R]): Pipe[F, NonEmptyList[String], DecoderResult[R]] = | ||
_.map(R(_)) | ||
/** Transforms a stream of raw CSV rows into rows, skipping the first line to ignore the headers. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First "line" is confusing in the context of CSV, I prefer to use "row", as it might span several lines.
2 minor comments, otherwise LGTM. |
Both addressed in afe6c82 :) |
Supersedes #15, see discussion there for motivating use cases.
Includes:
ParseableHeader
to parse all header columns at once to allow for more elaborated validationRow
class to represent csv rows without headers properlyCsvRow
acase class
extendingRow
and make headers non-optionalskipHeaders
andwithHeaders
pipes to cover all combinations of headers being present in the file and in the desired output