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.
- Companion:
- object
Value members
Concrete methods
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("")
.
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("")
.
Returns the decoded content of the cell at header
.
Fails if the field doesn't exist or cannot be decoded
to the expected type.
Returns the decoded content of the cell at header
.
Fails if the field doesn't exist or cannot be decoded
to the expected type.
Returns the decoded content of the cell at idx
.
Fails if the index doesn't exist or cannot be decoded
to the expected type.
Returns the decoded content of the cell at idx
.
Fails if the index doesn't exist or cannot be decoded
to the expected type.
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("")
.
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("")
.
Returns the row without the cell at the given header
.
If the resulting row is empty, returns None
.
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.
Returns the row without the cell at the given idx
.
If the resulting row is empty, returns None
.
Returns the row without the cell at the given idx
.
If the resulting row is empty, returns None
.
Drop all headers (if any).
Drop all headers (if any).
- Returns:
a row without headers, but same values
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.
Modifies the cell content at the given idx
using the function f
.
Modifies the cell content at the given idx
using the function f
.
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.
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.
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.
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.
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.