Packages

final case class CSVConfig extends Product with Serializable

CSV configuration used to create CSVParser or CSVRenderer.

This config may be used as a builder to create a parser :

val parser = CSVConfig().fieldSizeLimit(1000).noHeader.parser[IO]

or renderer:

val renderer = CSVConfig().escapeSpaces.noHeader.renderer[IO]

Field delimiter is ',' by default.

Record delimiter is '\n' by default. When the delimiter is set to line feed ('\n', ASCII 10) and it is preceded by carriage return ('\r', ASCII 13), they are treated as a single character.

Quotation mark is '"' by default. It is required to wrap special characters, field and record delimiters, in quotes. Quotation mark in actual content may appear only inside quotation marks. It has to be doubled to be interpreted as part of actual data, not a control character.

While parsing, the header setting defines if a header is present in source data, which is true by default. Header is used as keyset for actual values and not included in data. If there is no header, a number-based keys, in tuple style, are created (starting from "_1"). While rendering, the header setting defines if header row should be added to output. If no header is explicitly defined, a number-based one is used, like for parsing.

If CSV records are converted to case classes, header values are used as class fields and may require remapping. This can be achieved through mapHeader:

config.mapHeader(Map("first name" -> "firstName", "last name" -> "lastName")))

or if an implicit header is generated:

config.mapHeader(Map("_1" -> "firstName", "_2" -> "lastName")))

Header mapping may be also position-based, which is especially handy when there are duplicates in header and name-based remapping does not solve it (because it remaps all occurrences):

config.mapHeader(Map(0 -> "firstName", 1 -> "lastName")))

Remapping may be used for renderer as well, allowing customized header while converting data from case classes or tuples.

Unescaped fields with leading or trailing spaces may be automatically trimmed while parsing when trimSpaces is set to true. This setting is false by default and white spaces are preserved, even for unescaped fields.

Field size limit is used to stop processing input when it is significantly larger then expected to avoid OutOfMemoryError. This might happen if the source structure is invalid, e.g. the closing quotation mark is missing. There is no limit by default.

While rendering CSV content, different quoting polices may be used, which is controlled by escapeMode setting. By default only fields which contain field delimiter, record delimiter or quotation mark are put into quotes. When set to EscapeSpaces quotes are put additionally around fields with leading or trailing spaces. EscapeAll results in putting quotes around all fields.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CSVConfig
  2. Serializable
  3. Product
  4. Equals
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

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() @HotSpotIntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def escapeAll: CSVConfig

    Gets new config from this one by changing escape mode to quote all fields.

    Gets new config from this one by changing escape mode to quote all fields.

    Note

    This setting is used only by renderer and ignored by parser.

  8. val escapeMode: EscapeMode
  9. def escapeSpaces: CSVConfig

    Gets new config from this one by changing escape mode to quote fields with leading or trailing spaces.

    Gets new config from this one by changing escape mode to quote fields with leading or trailing spaces.

    Note

    This setting is used only by renderer and ignored by parser.

  10. def fieldDelimiter(fd: Char): CSVConfig

    Gets new config from this one by replacing field delimiter with provided one.

  11. val fieldDelimiter: Char
  12. def fieldSizeLimit(fsl: Int): CSVConfig

    Gets new config from this one by replacing field size limit with provided one.

    Gets new config from this one by replacing field size limit with provided one.

    Note

    This setting is used only by parser and ignored by renderer.

  13. val fieldSizeLimit: Option[Int]
  14. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. val hasHeader: Boolean
  16. val headerMap: HeaderMap
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def mapHeader(hm: HeaderMap): CSVConfig

    Remap selected fields names.

  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. def noHeader: CSVConfig

    Gets new config from this one by switching off header presence.

  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  23. def parser[F[_]](implicit arg0: Sync[F], arg1: Logger[F]): CSVParser[F]

    Creates CSVParser from this config.

    Creates CSVParser from this config.

    F

    the effect type, with a type class providing support for suspended execution (typically cats.effect.IO) and logging (provided internally by spata)

    returns

    parser configured according to provided settings

  24. def productElementNames: Iterator[String]
    Definition Classes
    Product
  25. def quoteMark(qm: Char): CSVConfig

    Gets new config from this one by replacing quotation mark with provided one.

  26. val quoteMark: Char
  27. def recordDelimiter(rd: Char): CSVConfig

    Gets new config from this one by replacing record delimiter with provided one.

  28. val recordDelimiter: Char
  29. def renderer[F[_]](implicit arg0: Sync[F], arg1: Logger[F]): CSVRenderer[F]

    Creates CSVRenderer from this config.

    Creates CSVRenderer from this config.

    F

    the effect type, with a type class providing support for suspended execution (typically cats.effect.IO) and logging (provided internally by spata)

    returns

    renderer configured according to provided settings

  30. def stripSpaces: CSVConfig

    Gets new config from this one by switching on stripping of unquoted, leading and trailing whitespaces.

    Gets new config from this one by switching on stripping of unquoted, leading and trailing whitespaces.

    Note

    This setting is used only by parser and ignored by renderer.

  31. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  32. def toString(): String

    Provides configuration description

    Provides configuration description

    returns

    short textual information about configuration

    Definition Classes
    CSVConfig → AnyRef → Any
  33. val trimSpaces: Boolean
  34. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  35. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  36. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped