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
Ordering
- Alphabetic
- By Inheritance
Inherited
- FromCsv
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- All
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- 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 ofcsvListany errors are reportedimport 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))))
- 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 ofcsv, any errors are reportedimport 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)))))
- 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 ofcsv, any errors are reportedimport 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)))
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()