Releases any resource used by this CsvReader.
Returns true
if there is at least one mor row to read, false
otherwise.
Reads the next CSV row.
Reads the next CSV row.
This method is not meant for internal purposes only and is not meant to be called directly. Use next instead.
Applies the specified partial function to all CSV rows.
Applies the specified partial function to all CSV rows.
Any row for which the function is not defined will be filtered out. All other rows will be replaced by the returned value.
This is particularly useful when dealing with kantan.csv.ReadResult: it's an easy way of skipping over all failures and keeping successes only:
val rows: CsvReader[(Int, String)] = file.asCsvReader[(Int, String)](',', true).collect { case Success(a) ¬ヌメ a }
partial function to apply to each row.
Discards the first n
rows.
Discards the first n
rows.
number of rows to discard.
Discards rows while the specified predicate holds.
Discards rows while the specified predicate holds.
The returned CsvReader will start at the first row for which p
returned false
.
predicate to apply to each row.
Filters out all rows that validate the specified predicate.
Filters out all rows that validate the specified predicate.
Working with CsvReader of ReadResult is such a common pattern that kantan.csv provides syntax for filtering directly into the ReadResult:
import kantan.csv.ops._ someFile.asCsvReader[Person](',', true).filterResult(_.age > 18)
Turns a CsvReader[A]
into a CsvReader[B]
.
Turns a CsvReader[A]
into a CsvReader[B]
.
function to apply to each row.
Turns a CsvReader[A]
into a CsvReader[B]
.
Turns a CsvReader[A]
into a CsvReader[B]
.
Working with CsvReader of ReadResult is such a common pattern that kantan.csv provides syntax for mapping directly into the ReadResult:
import kantan.csv.ops._ someFile.asCsvReader[Person](',', true).mapResult(_.name)
function to apply to each row.
Reads the next CSV row.
Reads the next CSV row.
This method will automatically call close if an error occurs or the end of the CSV data has been reached.
Takes the first n
rows, discarding the remaining ones.
Takes the first n
rows, discarding the remaining ones.
number of rows to take.
Iterator on CSV rows.
Instances of CsvReader are commonly obtained through kantan.csv.ops.CsvInputOps.asCsvReader:
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