guymers / ceesvee   1.0.1

MIT License GitHub

A CSV library designed for use with steams

Scala versions: 3.x 2.13


A CSV library designed for use with steams. Can be used with Iterator, fs2.Stream and

Supports the CSV format described by Model for Tabular Data and Metadata on the Web:

  • a new line can be \n or \r\n
  • a double quote is escaped by a double quote


case class Test(
  str: String,
  int: Int,
  bool: Boolean,
  optInt: Option[Int],
object Test {
  implicit val decoder: CsvRecordDecoder[Test] = CsvRecordDecoder.derive
  val header = ::("str", List("int", "bool", "opt_int"))
  val csvHeader = CsvHeader.create(header)(decoder)


val input: Iterator[String]
val result: Either[CsvHeader.MissingHeaders, Iterator[Either[CsvRecordDecoder.Error, Test]]] =
  CsvParser.decodeWithHeader(input, Test.csvHeader, options)


val stream: fs2.Stream[F[?], String]
val result: fs2.Stream[F[?], Either[CsvRecordDecoder.Error, Test]] = stream.through {
  Fs2CsvParser.decodeWithHeader(Test.csvHeader, options)


val stream:[R, E, String]
val result: zio.ZIO[
  Scope & R,
  Either[Either[E, CsvParser.Error], CsvHeader.MissingHeaders],[E, Either[E, CsvParser.Error], Either[CsvRecordDecoder.Error, Test]]
] = ZioCsvParser.decodeWithHeader(stream, Test.csvHeader, options)