final
class
CsvReader extends AbstractIterator[CellOrError]
Instance Constructors
-
new
CsvReader(input: Reader)
-
-
new
CsvReader(input: Reader, separator: Char)
Type Members
-
class
GroupedIterator[B >: A] extends AbstractIterator[Seq[B]] with Iterator[Seq[B]]
Value Members
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
def
++[B >: CellOrError](that: ⇒ GenTraversableOnce[B]): Iterator[B]
-
def
/:[B](z: B)(op: (B, CellOrError) ⇒ B): B
-
def
:\[B](z: B)(op: (CellOrError, B) ⇒ B): B
-
final
def
==(arg0: Any): Boolean
-
def
addString(b: StringBuilder): StringBuilder
-
def
addString(b: StringBuilder, sep: String): StringBuilder
-
def
addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder
-
def
aggregate[B](z: ⇒ B)(seqop: (B, CellOrError) ⇒ B, combop: (B, B) ⇒ B): B
-
final
def
asInstanceOf[T0]: T0
-
def
buffered: BufferedIterator[CellOrError]
-
def
clone(): AnyRef
-
def
collect[B](pf: PartialFunction[CellOrError, B]): Iterator[B]
-
def
collectFirst[B](pf: PartialFunction[CellOrError, B]): Option[B]
-
def
contains(elem: Any): Boolean
-
def
copyToArray[B >: CellOrError](xs: Array[B], start: Int, len: Int): Unit
-
def
copyToArray[B >: CellOrError](xs: Array[B]): Unit
-
def
copyToArray[B >: CellOrError](xs: Array[B], start: Int): Unit
-
def
copyToBuffer[B >: CellOrError](dest: Buffer[B]): Unit
-
def
corresponds[B](that: GenTraversableOnce[B])(p: (CellOrError, B) ⇒ Boolean): Boolean
-
def
count(p: (CellOrError) ⇒ Boolean): Int
-
def
drop(n: Int): Iterator[CellOrError]
-
-
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
exists(p: (CellOrError) ⇒ Boolean): Boolean
-
-
-
def
finalize(): Unit
-
-
def
flatMap[B](f: (CellOrError) ⇒ GenTraversableOnce[B]): Iterator[B]
-
def
fold[A1 >: CellOrError](z: A1)(op: (A1, A1) ⇒ A1): A1
-
def
foldLeft[B](z: B)(op: (B, CellOrError) ⇒ B): B
-
def
foldRight[B](z: B)(op: (CellOrError, B) ⇒ B): B
-
def
forall(p: (CellOrError) ⇒ Boolean): Boolean
-
def
foreach[U](f: (CellOrError) ⇒ U): Unit
-
final
def
getClass(): Class[_]
-
-
def
hasDefiniteSize: Boolean
-
def
hasNext: Boolean
-
def
hashCode(): Int
-
def
indexOf[B >: CellOrError](elem: B): Int
-
def
indexWhere(p: (CellOrError) ⇒ Boolean): Int
-
def
isEmpty: Boolean
-
final
def
isInstanceOf[T0]: Boolean
-
def
isTraversableAgain: Boolean
-
def
length: Int
-
def
map[B](f: (CellOrError) ⇒ B): Iterator[B]
-
-
def
maxBy[B](f: (CellOrError) ⇒ B)(implicit cmp: Ordering[B]): CellOrError
-
-
def
minBy[B](f: (CellOrError) ⇒ B)(implicit cmp: Ordering[B]): CellOrError
-
def
mkString: String
-
def
mkString(sep: String): String
-
def
mkString(start: String, sep: String, end: String): String
-
final
def
ne(arg0: AnyRef): Boolean
-
-
def
nextOption(): Option[CellOrError]
-
def
nonEmpty: Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
def
padTo[A1 >: CellOrError](len: Int, elem: A1): Iterator[A1]
-
-
def
patch[B >: CellOrError](from: Int, patchElems: Iterator[B], replaced: Int): Iterator[B]
-
def
product[B >: CellOrError](implicit num: Numeric[B]): B
-
def
reduce[A1 >: CellOrError](op: (A1, A1) ⇒ A1): A1
-
-
def
reduceLeftOption[B >: CellOrError](op: (B, CellOrError) ⇒ B): Option[B]
-
def
reduceOption[A1 >: CellOrError](op: (A1, A1) ⇒ A1): Option[A1]
-
-
def
reduceRightOption[B >: CellOrError](op: (CellOrError, B) ⇒ B): Option[B]
-
-
def
sameElements(that: Iterator[_]): Boolean
-
def
scanLeft[B](z: B)(op: (B, CellOrError) ⇒ B): Iterator[B]
-
def
scanRight[B](z: B)(op: (CellOrError, B) ⇒ B): Iterator[B]
-
val
separator: Char
-
-
def
size: Int
-
def
slice(from: Int, until: Int): Iterator[CellOrError]
-
-
-
def
sum[B >: CellOrError](implicit num: Numeric[B]): B
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
take(n: Int): Iterator[CellOrError]
-
-
def
throwOnError: Iterator[StringCell]
-
def
to[Col[_]](implicit cbf: CanBuildFrom[Nothing, CellOrError, Col[CellOrError]]): Col[CellOrError]
-
def
toArray[B >: CellOrError](implicit arg0: ClassTag[B]): Array[B]
-
def
toBuffer[B >: CellOrError]: Buffer[B]
-
def
toIndexedSeq: IndexedSeq[CellOrError]
-
def
toIterable: Iterable[CellOrError]
-
def
toIterator: Iterator[CellOrError]
-
-
def
toMap[T, U](implicit ev: <:<[CellOrError, (T, U)]): Map[T, U]
-
-
def
toSet[B >: CellOrError]: Set[B]
-
-
def
toString(): String
-
def
toTraversable: Traversable[CellOrError]
-
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
-
-
def
zip[B](that: Iterator[B]): Iterator[(CellOrError, B)]
-
def
zipAll[B, A1 >: CellOrError, B1 >: B](that: Iterator[B], thisElem: A1, thatElem: B1): Iterator[(A1, B1)]
-
def
zipWithIndex: Iterator[(CellOrError, Int)]
Inherited from AnyRef
Inherited from Any
This class is part of the lower level API for processing CSV data. This is a CSV parser that produces the data through the scala.collection.Iterator trait. The data is read into a sequence of StringCell instances. StringCells can be written back to disk with CsvWriter.
This class does parsing in streaming fashion ie. you should be able to handle files larger than what can fit in RAM, though this has not been tested yet. The actual parsing is delegated to CsvReaderInternal. This class just implements the Scala
Iterator
interface on top of CsvReaderInternal.Error handling
If an error is encountered in the input a CsvReaderError will be returned as the
Left
ofEither
. After this the iterator is exhausted andhasNext
will return false. Note that the input stream will be left open in this situation. Ifnext
is called whenhasNext
isfalse
, aNoSuchElementException
will be thrown as usual. See the method throwOnError for a shortcut to enable exception based error handling.Code example
This example code will pick the second column from the
csvData
and print thetoString
of eachCell
from that column. Note the use ofthrowOnError
to bypass theEither
normally returned by the reader.A note on closing the input stream. The java.io.Reader is closed only if the CSV data exhausted. In the case of an error and in the case of stopping to call the
read
method before the input ends it is the responsibility of the caller to close the stream.TableReader for a friendlier non streaming API.