Trait/Object

kantan.csv

CsvInput

Related Docs: object CsvInput | package csv

Permalink

trait CsvInput[-S] extends Serializable

Turns instances of S into valid sources of CSV data.

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

See the companion object for default implementations and construction methods.

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

Abstract Value Members

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

    Permalink

    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 CsvInput.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def contramap[T](f: (T) ⇒ S): CsvInput[T]

    Permalink

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

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

    This allows developers to adapt existing instances of CsvInput rather than write one from scratch. One could, for example, write CsvInput[String] by basing it on CsvInput[Reader]:

    val urlInput: CsvInput[String] = CsvInput[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

  7. def contramapResult[T](f: (T) ⇒ ParseResult[S]): CsvInput[T]

    Permalink

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

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

    This allows developers to adapt existing instances of CsvInput rather than write one from scratch. One could, for example, write CsvInput[URL] by basing it on CsvInput[InputStream]:

    val urlInput: CsvInput[URL] = CsvInput[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

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. 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]]

    Permalink

    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.

  18. def reader[A](s: S, sep: Char, header: Boolean)(implicit arg0: RowDecoder[A], e: ReaderEngine): CsvReader[ReadResult[A]]

    Permalink

    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.

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

    Permalink
    Definition Classes
    AnyRef
  20. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  21. def unsafeRead[C[_], A](s: S, separator: Char, header: Boolean)(implicit arg0: RowDecoder[A], e: ReaderEngine, cbf: CanBuildFrom[Nothing, A, C[A]]): C[A]

    Permalink

    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.

  22. def unsafeReader[A](s: S, separator: Char, header: Boolean)(implicit arg0: RowDecoder[A], engine: ReaderEngine): CsvReader[A]

    Permalink

    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.

  23. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped