kantan.csv

CsvSource

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]
Linear Supertypes
Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. CsvSource
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

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: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. 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 one from scratch. One could, for example, write CsvSource[String] by basing it on CsvSource[Reader]:

    val urlInput: CsvSource[String] = CsvSource[Reader].contramap((s: String) ¬ヌメ new java.io.StringReader(s))

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

    See also

    contramapResult

  9. def contramapResult[T](f: (T) ⇒ ParseResult[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 one from scratch. One could, for example, write CsvSource[URL] by basing it on CsvSource[InputStream]:

    val urlInput: CsvSource[URL] = CsvSource[InputStream].contramap((url: URL) ¬ヌメ url.openStream())

    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

  10. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  19. def read[C[_], A](s: S, sep: Char, header: Boolean)(implicit arg0: RowDecoder[A], e: ReaderEngine, cbf: CanBuildFrom[Nothing, 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.

    sep

    character used to separate columns.

    header

    whether or not the first row is a header. If set to true, the first row will be skipped entirely.

  20. def reader[A](s: S, sep: Char, header: Boolean)(implicit arg0: RowDecoder[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.

    Using common combinators such as map, flatMap and filter on a CsvReader[ReadResult[A]] can be awkward - one needs to first map into the reader, then into the result. For this reason, instances of CsvReader[ReadResult[A]] have dedicated syntax that makes it more pleasant through ops.CsvReaderOps.

    A

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

    s

    instance of S that will be opened an parsed.

    sep

    character used to separate columns.

    header

    whether or not the first row is a header. If set to true, the first row will be skipped entirely.

  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  22. def toString(): String

    Definition Classes
    AnyRef → Any
  23. def unsafeRead[C[_], A](s: S, separator: Char, header: Boolean)(implicit arg0: RowDecoder[A], e: ReaderEngine, cbf: CanBuildFrom[Nothing, 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.

    separator

    character used to separate columns.

    header

    whether or not the first row is a header. If set to true, the first row will be skipped entirely.

  24. def unsafeReader[A](s: S, separator: Char, header: Boolean)(implicit arg0: RowDecoder[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 RowDecoder instance in scope.

    s

    instance of S that will be opened an parsed.

    separator

    character used to separate columns.

    header

    whether or not the first row is a header. If set to true, the first row will be skipped entirely.

  25. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped