trait CsvSource[-S] extends Serializable

Turns instances of S into valid sources of CSV data.

Instances of CsvSource are rarely used directly. The preferred, idiomatic way is to use the implicit syntax provided by CsvSourceOps, brought in scope by importing kantan.csv.ops._.

See the companion object for default implementations and construction methods.

Self Type
CsvSource[S]
Source
CsvSource.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CsvSource
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def open(s: S): ParseResult[Reader]

    Turns the specified S into a Reader.

    Turns the specified S into a Reader.

    Implementations of this method *must* be safe: all non-fatal exceptions should be caught and wrapped in an ParseError.IOError. This is easily achieved by wrapping unsafe code in a call to ParseResult.apply.

    s

    instance of S to turn into a CsvSource.

Concrete 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[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. def contramap[T](f: (T) => S): CsvSource[T]

    Turns an instance of CsvSource[S] into one of CsvSource[T].

    Turns an instance of CsvSource[S] into one of CsvSource[T].

    This allows developers to adapt existing instances of CsvSource rather than write new ones from scratch.

    Note that this method assumes that the transformation from T to S is safe. If it fail, one should use econtramap instead.

    Example:
    1. scala> case class StringWrapper(value: String)
      
      scala> implicit val wrapperSource: CsvSource[StringWrapper] = CsvSource[String].contramap(_.value)
      
      scala> CsvSource[StringWrapper].unsafeRead[List, List[Int]](StringWrapper("1,2,3\n4,5,6"), rfc)
      res0: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6))
    See also

    econtramap

  7. def econtramap[SS <: S, T](f: (T) => ParseResult[SS]): CsvSource[T]

    Turns an instance of CsvSource[S] into one of CsvSource[T].

    Turns an instance of CsvSource[S] into one of CsvSource[T].

    This allows developers to adapt existing instances of CsvSource rather than write new ones from scratch.

    Example:
    1. scala> case class StringWrapper(value: String)
      
      scala> implicit val source: CsvSource[StringWrapper] = CsvSource[String].econtramap(s => ParseResult(s.value))
      
      scala> CsvSource[StringWrapper].unsafeRead[List, List[Int]](StringWrapper("1,2,3\n4,5,6"), rfc)
      res0: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6))

      Note that if the transformation from T to S is safe, it's better to use contramap and bypass the error handling mechanism altogether.

    See also

    contramap

  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  11. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. def read[C[_], A](s: S, conf: CsvConfiguration)(implicit arg0: HeaderDecoder[A], e: ReaderEngine, factory: Factory[ReadResult[A], C[ReadResult[A]]]): C[ReadResult[A]]

    Reads the entire CSV data into a collection.

    Reads the entire CSV data into a collection.

    This method is "safe", in that it does not throw exceptions when errors are encountered. This comes with the small cost of having each row wrapped in a ReadResult that then need to be unpacked. See unsafeRead for an alternative.

    C

    collection type in which to parse the specified S.

    A

    type in which to parse each row.

    s

    instance of S that will be opened an parsed.

    conf

    CSV parsing behaviour.

    Example:
    1. scala> CsvSource[String].read[List, List[Int]]("1,2,3\n4,5,6", rfc)
      res0: List[ReadResult[List[Int]]] = List(Right(List(1, 2, 3)), Right(List(4, 5, 6)))
  18. def reader[A](s: S, conf: CsvConfiguration)(implicit arg0: HeaderDecoder[A], e: ReaderEngine): CsvReader[ReadResult[A]]

    Turns the specified S into an iterator on ReadResult[A].

    Turns the specified S into an iterator on ReadResult[A].

    This method is "safe", in that it does not throw exceptions when errors are encountered. This comes with the small cost of having each row wrapped in a ReadResult that then need to be unpacked. See unsafeReader for an alternative.

    A

    type to parse each row as. This must have a corresponding implicit HeaderDecoder instance in scope.

    s

    instance of S that will be opened an parsed.

    conf

    CSV parsing behaviour.

    Example:
    1. scala> CsvSource[String].reader[List[Int]]("1,2,3\n4,5,6", rfc).toList
      res0: List[ReadResult[List[Int]]] = List(Right(List(1, 2, 3)), Right(List(4, 5, 6)))
  19. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. def unsafeRead[C[_], A](s: S, conf: CsvConfiguration)(implicit arg0: HeaderDecoder[A], e: ReaderEngine, factory: Factory[A, C[A]]): C[A]

    Reads the entire CSV data into a collection.

    Reads the entire CSV data into a collection.

    This is the "unsafe" version of read: it will throw as soon as an error is encountered.

    C

    collection type in which to parse the specified S.

    A

    type in which to parse each row.

    s

    instance of S that will be opened an parsed.

    conf

    CSV parsing behaviour.

    Example:
    1. scala> CsvSource[String].unsafeRead[List, List[Int]]("1,2,3\n4,5,6", rfc)
      res0: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6))
  22. def unsafeReader[A](s: S, conf: CsvConfiguration)(implicit arg0: HeaderDecoder[A], engine: ReaderEngine): CsvReader[A]

    Turns the specified S into an iterator on A.

    Turns the specified S into an iterator on A.

    This is the "unsafe" version of reader: it will throw as soon as an error is encountered.

    A

    type to parse each row as. This must have a corresponding implicit HeaderDecoder instance in scope.

    s

    instance of S that will be opened an parsed.

    conf

    CSV parsing behaviour.

    Annotations
    @SuppressWarnings()
    Example:
    1. scala> CsvSource[String].unsafeReader[List[Int]]("1,2,3\n4,5,6", rfc).toList
      res0: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6))
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Deprecated Value Members

  1. def contramapResult[SS <: S, T](f: (T) => ParseResult[SS]): CsvSource[T]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.3.2) Use econtramap instead

  2. def read[C[_], A](s: S, sep: Char, header: Boolean)(implicit arg0: HeaderDecoder[A], e: ReaderEngine, factory: Factory[ReadResult[A], C[ReadResult[A]]]): C[ReadResult[A]]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.1.18) use read(S, CsvConfiguration) instead

  3. def reader[A](s: S, sep: Char, header: Boolean)(implicit arg0: HeaderDecoder[A], e: ReaderEngine): CsvReader[ReadResult[A]]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.1.18) use reader(S, CsvConfiguration) instead

  4. def unsafeRead[C[_], A](s: S, sep: Char, header: Boolean)(implicit arg0: HeaderDecoder[A], e: ReaderEngine, factory: Factory[A, C[A]]): C[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.1.18) use unsafeRead(S, CsvConfiguration) instead

  5. def unsafeReader[A](s: S, sep: Char, header: Boolean)(implicit arg0: HeaderDecoder[A], engine: ReaderEngine): CsvReader[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.1.18) use unsafeReader(S, CsvConfiguration) instead

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped