RowF

fs2.data.csv.RowF
See theRowF companion object
case class RowF[H <: (Option), Header](values: NonEmptyList[String], headers: H[NonEmptyList[Header]], line: Option[Long])

A CSV row with or without headers. The presence of headers is encoded via the first type param which is a subtype of scala.Option. By preserving this information in types, it's possible to define Row and CsvRow aliases as if they were plain case classes while keeping the code DRY.

Operations on columns can always be performed using 0-based indices and additionally using a specified header value if headers are present (and this fact statically known).

Note: the following invariant holds when using this class: values and headers have the same size if headers are present.

Attributes

Companion
object
Source
RowF.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def apply(header: Header)(implicit hasHeaders: HasHeaders[H, Header]): Option[String]

Returns the content of the cell at header if it exists.

Returns the content of the cell at header if it exists. Returns None if header does not exist for the row. An empty cell value results in Some("").

Attributes

Source
RowF.scala
def as[T](header: Header)(implicit hasHeaders: HasHeaders[H, Header], decoder: CellDecoder[T]): DecoderResult[T]

Returns the decoded content of the cell at header.

Returns the decoded content of the cell at header. Fails if the field doesn't exist or cannot be decoded to the expected type.

Attributes

Source
RowF.scala
def asAt[T](idx: Int)(implicit decoder: CellDecoder[T]): DecoderResult[T]

Returns the decoded content of the cell at idx.

Returns the decoded content of the cell at idx. Fails if the index doesn't exist or cannot be decoded to the expected type.

Attributes

Source
RowF.scala
def asOptional[T](header: Header, missing: Header => DecoderResult[Option[T]], isEmpty: String => Boolean)(implicit hasHeaders: HasHeaders[H, Header], decoder: CellDecoder[T]): DecoderResult[Option[T]]

Returns the decoded content of the cell at header wrapped in Some if the cell is non-empty, None otherwise.

Returns the decoded content of the cell at header wrapped in Some if the cell is non-empty, None otherwise. The meaning of _empty_ can be tuned by setting providing a custom isEmpty predicate (by default, matches the empty string). In case the field does not exist, the missing parameter defines the behavior (by default, it faile) Fails if the index cannot be decoded to the expected type.

Attributes

Source
RowF.scala
def asOptionalAt[T](idx: Int, missing: Int => DecoderResult[Option[T]], isEmpty: String => Boolean)(implicit decoder: CellDecoder[T]): DecoderResult[Option[T]]

Returns the decoded content of the cell at idx wrapped in Some if the cell is non-empty, None otherwise.

Returns the decoded content of the cell at idx wrapped in Some if the cell is non-empty, None otherwise. The meaning of _empty_ can be tuned by setting providing a custom isEmpty predicate (by default, matches the empty string). In case the index does not exist, the missing parameter defines the behavior (by default, it faile) Fails if the index cannot be decoded to the expected type.

Attributes

Source
RowF.scala
def at(idx: Int): Option[String]

Returns the content of the cell at idx if it exists.

Returns the content of the cell at idx if it exists. Returns None if idx is out of row bounds. An empty cell value results in Some("").

Attributes

Source
RowF.scala
def delete(header: Header)(implicit hasHeaders: HasHeaders[H, Header]): Option[CsvRow[Header]]

Returns the row without the cell at the given header.

Returns the row without the cell at the given header. If the resulting row is empty, returns None.

**Note:** Only the first occurrence of the values with the given header will be deleted. It shouldn't be a problem in the general case as headers should not be duplicated.

Attributes

Source
RowF.scala
def deleteAt(idx: Int): Option[RowF[H, Header]]

Returns the row without the cell at the given idx.

Returns the row without the cell at the given idx. If the resulting row is empty, returns None.

Attributes

Source
RowF.scala

Drop all headers (if any).

Drop all headers (if any).

Attributes

Returns

a row without headers, but same values

Source
RowF.scala
def modify(header: Header)(f: String => String)(implicit hasHeaders: HasHeaders[H, Header]): CsvRow[Header]

Modifies the cell content at the given header using the function f.

Modifies the cell content at the given header using the function f.

**Note:** Only the first occurrence of the values with the given header will be modified. It shouldn't be a problem in the general case as headers should not be duplicated.

Attributes

Source
RowF.scala
def modifyAt(idx: Int)(f: String => String): RowF[H, Header]

Modifies the cell content at the given idx using the function f.

Modifies the cell content at the given idx using the function f.

Attributes

Source
RowF.scala
def set(header: Header, value: String)(implicit hasHeaders: HasHeaders[H, Header]): CsvRow[Header]

Returns the row with the cell at header modified to value.

Returns the row with the cell at header modified to value. If the header wasn't present in the row, it is added to the end of the fields.

**Note:** Only the first occurrence of the values with the given header will be modified. It shouldn't be a problem in the general case as headers should not be duplicated.

Attributes

Source
RowF.scala
def size: Int

Number of cells in the row.

Number of cells in the row.

Attributes

Source
RowF.scala
def toMap(implicit hasHeaders: HasHeaders[H, Header]): Map[Header, String]

Returns a representation of this row as Map from headers to corresponding cell values.

Returns a representation of this row as Map from headers to corresponding cell values.

Attributes

Source
RowF.scala
def toNonEmptyMap(implicit hasHeaders: HasHeaders[H, Header], order: Order[Header]): Type[Header, String]

Returns a representation of this row as NonEmptyMap from headers to corresponding cell values.

Returns a representation of this row as NonEmptyMap from headers to corresponding cell values.

Attributes

Source
RowF.scala
def updated(header: Header, value: String)(implicit hasHeaders: HasHeaders[H, Header]): CsvRow[Header]

Returns the row with the cell at header modified to value.

Returns the row with the cell at header modified to value.

**Note:** Only the first occurrence of the values with the given header will be modified. It shouldn't be a problem in the general case as headers should not be duplicated.

Attributes

Source
RowF.scala
def updatedAt(idx: Int, value: String): RowF[H, Header]

Returns the row with the cell at idx modified to value.

Returns the row with the cell at idx modified to value.

Attributes

Source
RowF.scala
def withLine(line: Option[Long]): RowF[H, Header]

Set the line number for this row.

Set the line number for this row.

Attributes

Source
RowF.scala

Deprecated methods

def asNonEmpty[T](header: Header)(implicit hasHeaders: HasHeaders[H, Header], decoder: CellDecoder[T]): DecoderResult[Option[T]]

Returns the decoded content of the cell at header wrapped in Some if the cell is non-empty, None otherwise.

Returns the decoded content of the cell at header wrapped in Some if the cell is non-empty, None otherwise. Fails if the field doesn't exist or cannot be decoded to the expected type.

Attributes

Deprecated
[Since version fs2-data 1.7.0] Use `RowF.asOptional` instead, as it gives more flexibility and has the same default behavior.
Source
RowF.scala
def asNonEmptyAt[T](idx: Int)(implicit decoder: CellDecoder[T]): DecoderResult[Option[T]]

Returns the decoded content of the cell at idx wrapped in Some if the cell is non-empty, None otherwise.

Returns the decoded content of the cell at idx wrapped in Some if the cell is non-empty, None otherwise. Fails if the index doesn't exist or cannot be decoded to the expected type.

Attributes

Deprecated
[Since version fs2-data 1.7.0] Use `RowF.asOptionalAt` instead, as it gives more flexibility and has the same default behavior.
Source
RowF.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product