Packages

object FromCsv

Converts a CSV to type

Since

0.0.1

See also

See test code for more information

See https://github.com/gekomad/itto-csv/blob/master/README.md for more information

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. FromCsv
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  9. def fromCsv[A](csvList: List[String])(implicit arg0: FieldNames[A], arg1: Schema[A], csvFormat: IttoCSVFormat): Seq[Either[NonEmptyList[ParseFailure], A]]

    csvList

    is the List[String] to parse

    csvFormat

    the com.github.gekomad.ittocsv.parser.IttoCSVFormat formatter

    returns

    Seq[Either[NonEmptyList[ParseFailure], A]] based on the parsing of csvList any errors are reported

    import com.github.gekomad.ittocsv.parser.IttoCSVFormat
    import com.github.gekomad.ittocsv.core.FromCsv._
    case class Foo(a: Int, b: Double, c: String, d: Boolean)
    implicit val csvFormat: IttoCSVFormat = IttoCSVFormat.default
    val p1 = fromCsv[Foo](List("1,3.14,foo,true", "2,3.14,bar,false"))
    assert(p1 == List(Right(Foo(1, 3.14, "foo", true)), Right(Foo(2, 3.14, "bar", false))))
  10. def fromCsv[A](csv: String)(implicit arg0: FieldNames[A], arg1: Schema[A], csvFormat: IttoCSVFormat): Seq[Either[NonEmptyList[ParseFailure], A]]

    csv

    is the string to parse. It might contain record separator

    csvFormat

    the com.github.gekomad.ittocsv.parser.IttoCSVFormat formatter

    returns

    Seq[Either[NonEmptyList[ParseFailure], A]] based on the parsing of csv, any errors are reported

    import com.github.gekomad.ittocsv.core.FromCsv._
    implicit val csvFormat = com.github.gekomad.ittocsv.parser.IttoCSVFormat.default
    
    case class Bar(a: String, b: Int)
    
    assert(fromCsv[Bar]("abc,42\r\nfoo,24") == List(Right(Bar("abc", 42)), Right(Bar("foo", 24))))
    assert(fromCsv[Bar]("abc,hi") == List(Left(cats.data.NonEmptyList(com.github.gekomad.ittocsv.core.FromCsv.ParseFailure("Not a Int hi"), Nil))))
    
    case class Foo(v: String, a: List[Int])
    assert(fromCsv[Foo]("abc,\"1,2,3\"") == List(Right(Foo("abc", List(1, 2, 3)))))
  11. def fromCsvL[A](csv: String)(implicit arg0: ConvertTo[A], csvFormat: IttoCSVFormat): Seq[Either[ParseFailure, A]]

    csv

    is the string to parse. It might contain record separator

    csvFormat

    the com.github.gekomad.ittocsv.parser.IttoCSVFormat formatter

    returns

    Seq[Either[ParseFailure, A]] based on the parsing of csv, any errors are reported

    import com.github.gekomad.ittocsv.core.FromCsv._
    
    implicit val csvFormat = com.github.gekomad.ittocsv.parser.IttoCSVFormat.default
    
    assert(fromCsvL[Double]("1.1,2.1,3.1") == List(Right(1.1), Right(2.1), Right(3.1)))
    assert(fromCsvL[Double]("1.1,abc,3.1") == List(Right(1.1), Left(com.github.gekomad.ittocsv.core.FromCsv.ParseFailure("Not a Double abc")), Right(3.1)))
  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  19. def toString(): String
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped