Package

kantan

csv

Permalink

package csv

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

Type Members

  1. type CellCodec[A] = Codec[String, A, DecodeError, codecs.type]

    Permalink

    Aggregates a CellEncoder and a CellDecoder.

    Aggregates a CellEncoder and a CellDecoder.

    The sole purpose of this type class is to provide a convenient way to create encoders and decoders. It should not be used directly for anything but instance creation - in particular, it should never be used in a context bound or expected as an implicit parameter.

    See also

    kantan.codecs.Codec

  2. trait CellCodecInstances extends CellEncoderInstances with CellDecoderInstances

    Permalink
  3. type CellDecoder[A] = Decoder[String, A, DecodeError, codecs.type]

    Permalink

    Describes how to decode CSV cells into specific types.

    Describes how to decode CSV cells into specific types.

    All types A such that there exists an implicit instance of CellDecoder[A] in scope can be decoded from CSV cells.

    Note that instances of this type class are rarely used directly - their purpose is to be implicitly assembled into more complex instances of kantan.csv.RowDecoder.

    See the companion object for creation and summoning methods.

    See also

    kantan.codecs.Decoder

  4. trait CellDecoderInstances extends AnyRef

    Permalink

    All default CellDecoder instances.

  5. type CellEncoder[A] = Encoder[String, A, codecs.type]

    Permalink

    Describes how to encode values of a specific type to CSV cells.

    Describes how to encode values of a specific type to CSV cells.

    All types A such that there exists an implicit instance of CellEncoder[A] in scope can be encoded to CSV cells.

    Note that instances of this type class are rarely used directly - their purpose is to be implicitly assembled into more complex instances of RowEncoder.

    See the companion object for creation and summoning methods.

    See also

    kantan.codecs.Encoder

  6. trait CellEncoderInstances extends AnyRef

    Permalink

    All default CellEncoder instances.

  7. trait CsvInput[-S] extends Serializable

    Permalink

    Turns instances of S into valid sources of CSV data.

    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.

  8. trait CsvOutput[-S] extends Serializable

    Permalink

    Type class for all types that can be turned into CsvWriter instances.

    Type class for all types that can be turned into CsvWriter instances.

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

    See the companion object for default implementations and construction methods.

  9. trait CsvReader[+A] extends TraversableOnce[A] with Closeable

    Permalink

    Iterator on CSV rows.

    Iterator on CSV rows.

    Instances of CsvReader are commonly obtained through kantan.csv.ops.CsvInputOps.asCsvReader:

    import kantan.csv.ops._
    
    val file: File = ??? // some CSV file.
    file.asCsvReader[List[Int]](',', true)

    CsvReader provides most of the common Scala collection operations, such as map or filter. However, working with a CsvReader of ReadResult is a very common pattern that doesn't lend itself well to using such combinators: mapping on each row would require first mapping into the CsvReader, then into each ReadResult, which is cumbersome and not terribly clear.

    kantan.csv provides syntax for this pattern with kantan.csv.ops.CsvReaderOps: filtering into a result, for example, is made easier by kantan.csv.ops.CsvReaderOps.filterResult

    import kantan.csv.ops._
    
    file.asCsvReader[List[Int]](',', true).filterResult(_ % 2 == 0)
  10. trait CsvWriter[A] extends Closeable

    Permalink

    Type of values that know how to write CSV data.

    Type of values that know how to write CSV data.

    There should almost never be a reason to implement this trait directly. The default implementation should satisfy most needs, and others can be swapped if needed through the kantan.csv.engine.WriterEngine mechanism.

    A

    type of values that will be encoded as CSV.

  11. sealed abstract class DecodeError extends ReadError

    Permalink

    Parent type for all errors that can occur while decoding CSV data.

  12. type DecodeResult[A] = Result[DecodeError, A]

    Permalink

    Result of a decode operation, which can be either a success or a failure.

    Result of a decode operation, which can be either a success or a failure.

    The difference between a parse and a decode result is that the former comes from reading raw data and trying to interpret it as CSV, while the later comes from turning CSV data into useful Scala types.

    Failure cases are all encoded as DecodeError.

    See also

    kantan.codecs.Result

  13. trait GeneratedRowCodecs extends AnyRef

    Permalink
  14. trait GeneratedRowDecoders extends AnyRef

    Permalink
  15. trait GeneratedRowEncoders extends AnyRef

    Permalink
  16. trait LowPriorityCsvInputs extends AnyRef

    Permalink
  17. sealed abstract class ParseError extends ReadError

    Permalink
  18. type ParseResult[A] = Result[ParseError, A]

    Permalink

    Result of a parsing operation, which can be either a success or a failure.

    Result of a parsing operation, which can be either a success or a failure.

    The difference between a parse and a decode result is that the former comes from reading raw data and trying to interpret it as CSV, while the later comes from turning CSV data into useful Scala types.

    Failure cases are all encoded as ParseError.

    See also

    kantan.codecs.Result

  19. sealed abstract class ReadError extends Product with Serializable

    Permalink

    Parent type for all errors that can occur while dealing with CSV data.

    Parent type for all errors that can occur while dealing with CSV data.

    ReadError is split into two main error types:

    • DecodeError: errors that occur while decoding a cell or a row.
    • ParseError: errors that occur while parsing raw data into CSV.
  20. type ReadResult[A] = Result[ReadError, A]

    Permalink

    Result of a reading operation, which can be either a success or a failure.

    Result of a reading operation, which can be either a success or a failure.

    Both ParseResult and DecodeResult are valid values of type ReadResult.

    See also

    kantan.codecs.Result

  21. type RowCodec[A] = Codec[Seq[String], A, DecodeError, codecs.type]

    Permalink

    Aggregates a RowEncoder and a RowDecoder.

    Aggregates a RowEncoder and a RowDecoder.

    The sole purpose of this type class is to provide a convenient way to create encoders and decoders. It should not be used directly for anything but instance creation - in particular, it should never be used in a context bound or expected as an implicit parameter.

    See also

    kantan.codecs.Codec

  22. trait RowCodecInstances extends RowEncoderInstances with RowDecoderInstances

    Permalink
  23. type RowDecoder[A] = Decoder[Seq[String], A, DecodeError, codecs.type]

    Permalink

    Describes how to decode CSV rows into specific types.

    Describes how to decode CSV rows into specific types.

    All types A such that there exists an implicit instance of RowDecoder[A] in scope can be decoded from CSV rows by functions such as CsvInput.reader or CsvInput.read.

    See the companion object for creation and summoning methods.

    See also

    kantan.codecs.Decoder

  24. trait RowDecoderInstances extends AnyRef

    Permalink

    Provides reasonable default RowDecoder instances for various types.

  25. type RowEncoder[A] = Encoder[Seq[String], A, codecs.type]

    Permalink

    Describes how to encode values of a specific type to CSV rows.

    Describes how to encode values of a specific type to CSV rows.

    All types A such that there exists an implicit instance of RowEncoder[A] in scope can be encoded to CSV rows by functions such as CsvOutput.writer or CsvOutput.write.

    See the companion object for creation and summoning methods.

    See also

    kantan.codecs.Encoder

  26. trait RowEncoderInstances extends AnyRef

    Permalink

    Provides reasonable default RowEncoder instances for various types.

  27. trait TupleInstances extends AnyRef

    Permalink

Value Members

  1. object CellCodec

    Permalink

    Declares helpful methods for CellCodec creation.

  2. object CellDecoder

    Permalink

    Provides useful methods for summoning and creating instances of CellDecoder.

  3. object CellEncoder

    Permalink

    Provides useful methods for summoning and creating instances of CellEncoder.

  4. object CsvInput extends LowPriorityCsvInputs with Serializable

    Permalink

    Defines convenience methods for creating and retrieving instances of CsvInput.

    Defines convenience methods for creating and retrieving instances of CsvInput.

    Implicit default implementations of standard types are also declared here, always bringing them in scope with a low priority.

    These default implementations can also be useful when writing more complex instances: if you need to write a CsvInput[T] and have both a CsvInput[S] and a T ⇒ S, you need just use CsvInput.contramap to create your implementation.

  5. object CsvOutput extends Serializable

    Permalink

    Provides default instances as well as instance summoning and creation methods.

  6. object CsvReader

    Permalink

    Provides instance creation and summoning methods.

  7. object CsvWriter

    Permalink

    Provides useful instance creation methods.

  8. object DecodeError extends Serializable

    Permalink

    Declares all possible values of type DecodeError.

  9. object DecodeResult

    Permalink
  10. object ParseError extends Serializable

    Permalink
  11. object ParseResult

    Permalink
  12. object RowCodec extends GeneratedRowCodecs

    Permalink

    Provides useful methods for RowCodec instance creation.

  13. object RowDecoder extends GeneratedRowDecoders

    Permalink

    Provides various instance creation and summoning methods.

    Provides various instance creation and summoning methods.

    The instance creation functions are important to know about, as they make the task of creating new decoders easier and more correct. There are two main families, depending on the type to decode:

    • decoder: creates decoders from a function of arity XXX and for which you need to specify a mapping parameter to row index (such as if the order in which cells are written doesn't match that of the function's parameters).
    • ordered: create decoders from a function of arity XXX such that its parameters are organised in exactly the same way as CSV rows.

    Note that a lot of types already have implicit instances: tuples, collections... moreover, the generics module can automatically derive valid instances for a lot of common scenarios.

  14. object RowEncoder extends GeneratedRowEncoders

    Permalink

    Provides various instance creation and summoning methods.

    Provides various instance creation and summoning methods.

    The instance creation functions are important to know about, as they make the task of creating new encoders easier and more correct. There are four main families, depending on the type to encode:

    • encoder: creates encoders from a function for which you need to specify a mapping row index to parameter (such as if you need to skip some CSV cells, for instance).
    • ordered: create encoders from a function such that its parameters are organised in exactly the same way as CSV rows.
    • caseEncoder: specialisation of encoder for case classes.
    • caseOrdered: specialisation of ordered for case classes.

    Note that a lot of types already have implicit instances: tuples, collections... moreover, the generics module can automatically derive valid instances for a lot of common scenarios.

  15. object codecs extends CellCodecInstances with RowCodecInstances with TupleInstances

    Permalink
  16. package engine

    Permalink
  17. object ops

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped