hammerlab / string-utils   1.2.0

Apache License 2.0 GitHub

String/CSV utilities

Scala versions: 2.12 2.11 2.10

strings

Build Status Coverage Status Maven Central

String/CSV utilities.

Interface for classes that can render themselves as an Iterator[String], exposing a .toString() that will be truncated to a maximum number of characters.

Convert collections of case classes (really Products) to CSV rows:

scala> import org.hammerlab.csv._
scala> case class Foo(num: Int, str: String)
scala> Seq(Foo(123, "abc"), Foo(456, "xyz")).toCSV()
res5: Iterator[String] = non-empty iterator
scala> Seq(Foo(123, "abc"), Foo(456, "xyz")).toCSV().mkString("\n")
res6: String =
num,str
123,abc
456,xyz

See the tests for more examples, including how to convert non-case-classes.