Trait/Object

kantan.csv

CsvReader

Related Docs: object CsvReader | package csv

Permalink

trait CsvReader[+A] extends TraversableOnce[A] with Closeable

Iterator on CSV rows.

Instances of CsvReader are commonly obtained through kantan.csv.ops.CsvInputOps.asCsvReader:

import kantan.csv.ops._

val file: File = ??? // some CSV file.
file.asCsvReader[List[Int]](',', true)

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

import kantan.csv.ops._

file.asCsvReader[List[Int]](',', true).filterResult(_ % 2 == 0)
Self Type
CsvReader[A]
Linear Supertypes
Closeable, AutoCloseable, TraversableOnce[A], GenTraversableOnce[A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CsvReader
  2. Closeable
  3. AutoCloseable
  4. TraversableOnce
  5. GenTraversableOnce
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def close(): Unit

    Permalink

    Releases any resource used by this CsvReader.

    Releases any resource used by this CsvReader.

    This happens automatically whenever a fatal error occurs or there is no more CSV rows to read. Applications that do not read the entire stream, however, need to call close manually.

    Definition Classes
    CsvReader → Closeable → AutoCloseable
  2. abstract def hasNext: Boolean

    Permalink

    Returns true if there is at least one mor row to read, false otherwise.

  3. abstract def readNext(): A

    Permalink

    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.

    Attributes
    protected

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def /:[B](z: B)(op: (B, A) ⇒ B): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  4. def :\[B](z: B)(op: (A, B) ⇒ B): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. def addString(b: StringBuilder): StringBuilder

    Permalink
    Definition Classes
    TraversableOnce
  7. def addString(b: StringBuilder, sep: String): StringBuilder

    Permalink
    Definition Classes
    TraversableOnce
  8. def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder

    Permalink
    Definition Classes
    TraversableOnce
  9. def aggregate[B](z: ⇒ B)(seqop: (B, A) ⇒ B, combop: (B, B) ⇒ B): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  10. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  11. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def collect[B](f: PartialFunction[A, B]): CsvReader[B]

    Permalink

    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
    }
    f

    partial function to apply to each row.

  13. def collectFirst[B](pf: PartialFunction[A, B]): Option[B]

    Permalink
    Definition Classes
    TraversableOnce
  14. def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit

    Permalink
    Definition Classes
    CsvReader → TraversableOnce → GenTraversableOnce
  15. def copyToArray[B >: A](xs: Array[B]): Unit

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  16. def copyToArray[B >: A](xs: Array[B], start: Int): Unit

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  17. def copyToBuffer[B >: A](dest: Buffer[B]): Unit

    Permalink
    Definition Classes
    TraversableOnce
  18. def count(p: (A) ⇒ Boolean): Int

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  19. def drop(n: Int): CsvReader[A]

    Permalink

    Discards the first n rows.

    Discards the first n rows.

    n

    number of rows to discard.

  20. def dropWhile(p: (A) ⇒ Boolean): CsvReader[A]

    Permalink

    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.

    p

    predicate to apply to each row.

  21. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  23. def exists(p: (A) ⇒ Boolean): Boolean

    Permalink
    Definition Classes
    CsvReader → TraversableOnce → GenTraversableOnce
  24. def filter(p: (A) ⇒ Boolean): CsvReader[A]

    Permalink

    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)
  25. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  26. def find(p: (A) ⇒ Boolean): Option[A]

    Permalink
    Definition Classes
    CsvReader → TraversableOnce → GenTraversableOnce
  27. def flatMap[B](f: (A) ⇒ CsvReader[B]): CsvReader[B]

    Permalink

    Turns a CsvReader[A] into a CsvReader[B].

    Turns a CsvReader[A] into a CsvReader[B].

    f

    function to apply to each row.

  28. def fold[A1 >: A](z: A1)(op: (A1, A1) ⇒ A1): A1

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  29. def foldLeft[B](z: B)(op: (B, A) ⇒ B): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  30. def foldRight[B](z: B)(op: (A, B) ⇒ B): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  31. def forall(p: (A) ⇒ Boolean): Boolean

    Permalink
    Definition Classes
    CsvReader → TraversableOnce → GenTraversableOnce
  32. def foreach[U](f: (A) ⇒ U): Unit

    Permalink
    Definition Classes
    CsvReader → TraversableOnce → GenTraversableOnce
  33. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  34. def hasDefiniteSize: Boolean

    Permalink
    Definition Classes
    CsvReader → TraversableOnce → GenTraversableOnce
  35. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  36. def isEmpty: Boolean

    Permalink
    Definition Classes
    CsvReader → TraversableOnce → GenTraversableOnce
  37. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  38. def isTraversableAgain: Boolean

    Permalink
    Definition Classes
    CsvReader → GenTraversableOnce
  39. def map[B](f: (A) ⇒ B): CsvReader[B]

    Permalink

    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)
    f

    function to apply to each row.

  40. def max[B >: A](implicit cmp: Ordering[B]): A

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  41. def maxBy[B](f: (A) ⇒ B)(implicit cmp: Ordering[B]): A

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  42. def min[B >: A](implicit cmp: Ordering[B]): A

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  43. def minBy[B](f: (A) ⇒ B)(implicit cmp: Ordering[B]): A

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  44. def mkString: String

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  45. def mkString(sep: String): String

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  46. def mkString(start: String, sep: String, end: String): String

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  47. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  48. def next(): A

    Permalink

    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.

  49. def nonEmpty: Boolean

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  50. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  51. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  52. def product[B >: A](implicit num: Numeric[B]): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  53. def reduce[A1 >: A](op: (A1, A1) ⇒ A1): A1

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  54. def reduceLeft[B >: A](op: (B, A) ⇒ B): B

    Permalink
    Definition Classes
    TraversableOnce
  55. def reduceLeftOption[B >: A](op: (B, A) ⇒ B): Option[B]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  56. def reduceOption[A1 >: A](op: (A1, A1) ⇒ A1): Option[A1]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  57. def reduceRight[B >: A](op: (A, B) ⇒ B): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  58. def reduceRightOption[B >: A](op: (A, B) ⇒ B): Option[B]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  59. def reversed: List[A]

    Permalink
    Attributes
    protected[this]
    Definition Classes
    TraversableOnce
  60. def seq: TraversableOnce[A]

    Permalink
    Definition Classes
    CsvReader → TraversableOnce → GenTraversableOnce
  61. def size: Int

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  62. def sum[B >: A](implicit num: Numeric[B]): B

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  63. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  64. def take(n: Int): CsvReader[A]

    Permalink

    Takes the first n rows, discarding the remaining ones.

    Takes the first n rows, discarding the remaining ones.

    n

    number of rows to take.

  65. def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A]]): Col[A]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  66. def toArray[B >: A](implicit arg0: ClassTag[B]): Array[B]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  67. def toBuffer[B >: A]: Buffer[B]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  68. def toIndexedSeq: IndexedSeq[A]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  69. def toIterable: Iterable[A]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  70. def toIterator: Iterator[A]

    Permalink
    Definition Classes
    CsvReader → GenTraversableOnce
  71. def toList: List[A]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  72. def toMap[T, U](implicit ev: <:<[A, (T, U)]): Map[T, U]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  73. def toSeq: Seq[A]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  74. def toSet[B >: A]: Set[B]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  75. def toStream: Stream[A]

    Permalink
    Definition Classes
    CsvReader → GenTraversableOnce
  76. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  77. def toTraversable: Traversable[A]

    Permalink
    Definition Classes
    CsvReader → TraversableOnce → GenTraversableOnce
  78. def toVector: Vector[A]

    Permalink
    Definition Classes
    TraversableOnce → GenTraversableOnce
  79. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  80. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  81. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  82. def withFilter(p: (A) ⇒ Boolean): CsvReader[A]

    Permalink

Inherited from Closeable

Inherited from AutoCloseable

Inherited from TraversableOnce[A]

Inherited from GenTraversableOnce[A]

Inherited from AnyRef

Inherited from Any

Ungrouped