Turns the specified S
into a Reader
.
Turns the specified S
into a Reader
.
Implementations of this method *must* be safe: all non-fatal exceptions should be caught and wrapped in an ParseError.IOError. This is easily achieved by wrapping unsafe code in a call to ParseResult.apply.
instance of S
to turn into a CsvInput.
Turns an instance of CsvInput[S]
into one of CsvInput[T]
.
Turns an instance of CsvInput[S]
into one of CsvInput[T]
.
This allows developers to adapt existing instances of CsvInput rather than write one from scratch.
One could, for example, write CsvInput[String]
by basing it on CsvInput[Reader]
:
val urlInput: CsvInput[String] = CsvInput[Reader].contramap((s: String) ¬ヌメ new java.io.StringReader(s))
Note that this method assumes that the transformation from T
to S
is safe. If it fail, one should use
contramapResult instead.
Turns an instance of CsvInput[S]
into one of CsvInput[T]
.
Turns an instance of CsvInput[S]
into one of CsvInput[T]
.
This allows developers to adapt existing instances of CsvInput rather than write one from scratch.
One could, for example, write CsvInput[URL]
by basing it on CsvInput[InputStream]
:
val urlInput: CsvInput[URL] = CsvInput[InputStream].contramap((url: URL) ¬ヌメ url.openStream())
Note that if the transformation from T
to S
is safe, it's better to use contramap and bypass the error
handling mechanism altogether.
Reads the entire CSV data into a collection.
Reads the entire CSV data into a collection.
This method is "safe", in that it does not throw exceptions when errors are encountered. This comes with the small cost of having each row wrapped in a ReadResult that then need to be unpacked. See unsafeRead for an alternative.
collection type in which to parse the specified S
.
type in which to parse each row.
instance of S
that will be opened an parsed.
character used to separate columns.
whether or not the first row is a header. If set to true
, the first row will be skipped entirely.
Turns the specified S
into an iterator on ReadResult[A]
.
Turns the specified S
into an iterator on ReadResult[A]
.
This method is "safe", in that it does not throw exceptions when errors are encountered. This comes with the small cost of having each row wrapped in a ReadResult that then need to be unpacked. See unsafeReader for an alternative.
Using common combinators such as map
, flatMap
and filter
on a CsvReader[ReadResult[A]]
can be awkward -
one needs to first map into the reader, then into the result. For this reason, instances of
CsvReader[ReadResult[A]]
have dedicated syntax that makes it more pleasant through ops.CsvReaderOps.
type to parse each row as. This must have a corresponding implicit RowDecoder instance in scope.
instance of S
that will be opened an parsed.
character used to separate columns.
whether or not the first row is a header. If set to true
, the first row will be skipped entirely.
Reads the entire CSV data into a collection.
Reads the entire CSV data into a collection.
This is the "unsafe" version of read: it will throw as soon as an error is encountered.
collection type in which to parse the specified S
.
type in which to parse each row.
instance of S
that will be opened an parsed.
character used to separate columns.
whether or not the first row is a header. If set to true
, the first row will be skipped entirely.
Turns the specified S
into an iterator on A
.
Turns the specified S
into an iterator on A
.
This is the "unsafe" version of reader: it will throw as soon as an error is encountered.
type to parse each row as. This must have a corresponding implicit RowDecoder instance in scope.
instance of S
that will be opened an parsed.
character used to separate columns.
whether or not the first row is a header. If set to true
, the first row will be skipped entirely.
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.