banno / banno-csv

Typesafe CSV parsing



Typesafe CSV parsing in scala.


  1. Read file in as a String
  2. Parse
val csvFileAsString = "..."

// parsed.rows must contain(exactly(ParsedCSVRow(Map(("First Name" -> "Frank"),
//                                                   ("Last Name" -> "Bob"),
//                                                   ("Email" -> "")))))

You can use Banno-csv to convert a CSV string to a case class.

  1. Create your case class that will represent a CSV row
  2. Add an implicit Formats in your case class' companion object.
  3. Then use the CSVParser object's .parseCSVTo function to convert it.
case class Person(first: String, last: String, age: Int)
object Person {
  implicit val personFormat = CSVProductFormats.productFormat3("First Name", "Last Name", "Age")(Person.apply)(Person.unapply)

CSVParser.parseCSVTo[Person]("csv as string")

//Success(Seq(Person("Frank", "Bob", "45"), ...))

Get banno-csv

In your build.sbt

resolvers += "bintray-banno-oss-releases" at ""

libraryDependencies ++= Seq(
  "com.banno" %% "banno-csv" % "1.1.0"


Fork away, commit, and send a pull request. Make sure that the tests pass before you submit your pull request.