CsvSourceOps
Provides useful syntax for types that have implicit instances of CsvSource in scope.
The most common use case is to turn a value into a CsvReader:
scala> import kantan.csv._
scala> "1,2,3\n4,5,6".asCsvReader[List[Int]](rfc).toList
res0: List[ReadResult[List[Int]]] = List(Right(List(1, 2, 3)), Right(List(4, 5, 6)))
A slightly less common use case is to load an entire CSV file in memory:
scala> "1,2,3\n4,5,6".readCsv[List, List[Int]](rfc)
res1: List[ReadResult[List[Int]]] = List(Right(List(1, 2, 3)), Right(List(4, 5, 6)))
Unsafe versions of these methods are also available, even if usually advised against.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
Opens a CsvReader on the underlying resource.
Opens a CsvReader on the underlying resource.
This is a convenience method only, and strictly equivalent to:
scala> import kantan.csv._
scala> CsvSource[String].reader[List[Int]]("1,2,3\n4,5,6", rfc).toList
res1: List[ReadResult[List[Int]]] = List(Right(List(1, 2, 3)), Right(List(4, 5, 6)))
Type parameters
- B
-
type each row will be decoded as.
Value parameters
- conf
-
CSV parsing behaviour.
Attributes
- Example
-
scala> import kantan.csv._ scala> "1,2,3\n4,5,6".asCsvReader[List[Int]](rfc).toList res0: List[ReadResult[List[Int]]] = List(Right(List(1, 2, 3)), Right(List(4, 5, 6)))
Opens an unsafe CsvReader on the underlying resource.
Opens an unsafe CsvReader on the underlying resource.
This is a convenience method only, and strictly equivalent to:
scala> import kantan.csv._
scala> CsvSource[String].unsafeReader[List[Int]]("1,2,3\n4,5,6", rfc).toList
res1: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6))
Type parameters
- B
-
type each row will be decoded as.
Value parameters
- conf
-
CSV parsing behaviour.
Attributes
- Example
-
scala> import kantan.csv._ scala> "1,2,3\n4,5,6".asUnsafeCsvReader[List[Int]](rfc).toList res0: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6))
Reads the underlying resource as a CSV stream.
Reads the underlying resource as a CSV stream.
This is a convenience method only, and strictly equivalent to:
scala> import kantan.csv._
scala> CsvSource[String].read[List, List[Int]]("1,2,3\n4,5,6", rfc)
res1: List[ReadResult[List[Int]]] = List(Right(List(1, 2, 3)), Right(List(4, 5, 6)))
Type parameters
- B
-
type each row will be decoded as.
- C
-
type of the collection in which the decoded CSV data will be stored.
Value parameters
- conf
-
CSV parsing behaviour.
Attributes
- Example
-
scala> import kantan.csv._ scala> "1,2,3\n4,5,6".readCsv[List, List[Int]](rfc) res0: List[ReadResult[List[Int]]] = List(Right(List(1, 2, 3)), Right(List(4, 5, 6)))
Reads the underlying resource as a CSV stream (unsafely).
Reads the underlying resource as a CSV stream (unsafely).
This is a convenience method only, and strictly equivalent to:
scala> import kantan.csv._
scala> CsvSource[String].unsafeRead[List, List[Int]]("1,2,3\n4,5,6", rfc)
res1: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6))
Type parameters
- B
-
type each row will be decoded as.
- C
-
type of the collection in which the decoded CSV data will be stored.
Value parameters
- conf
-
CSV parsing behaviour.
Attributes
- Example
-
scala> import kantan.csv._ scala> "1,2,3\n4,5,6".unsafeReadCsv[List, List[Int]](rfc) res0: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6))
Deprecated methods
Attributes
- Deprecated
- true
Attributes
- Deprecated
- true
Attributes
- Deprecated
- true
Attributes
- Deprecated
- true