object CsvIO
This package uses a CSV mapper called Kantan.
import the following:
import kantan.csv._ import com.spotify.scio.extra.csv._
Reading
with a header
case class User(name: String, age: Int) implicit val decoder = HeaderDecoder.decoder("fullName", "userAge")(User.apply _) val users: SCollection[User] = scioContext.csvFile(path)
without a header
case class User(name: String, age: Int) implicit val decoder = RowDecoder.ordered { (name: String, age: Int) => User(name, age) } val csvConfiguration = CsvIO.ReadParam(csvConfiguration = CsvIO.DefaultCsvConfiguration.withoutHeader) val users: SCollection[User] = scioContext.csvFile(path, csvConfiguration)
Writing
with a header
case class User(name: String, age: Int) implicit val encoder = HeaderEncoder.caseEncoder("fullName", "age")(User.unapply) val users: SCollection[User] = ??? users.saveAsCsvFile(path)
without a header
case class User(name: String, age: Int) implicit val encoder = RowEncoder.encoder(0, 1)((u: User) => (u.name, u.age)) val users: SCollection[User] = ??? users.saveAsCsvFile(path)
- Source
- CsvIO.scala
Linear Supertypes
Ordering
- Alphabetic
- By Inheritance
Inherited
- CsvIO
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- Protected
Type Members
- final case class Read[T](path: String)(implicit evidence$1: HeaderDecoder[T], evidence$2: Coder[T]) extends ScioIO[T] with Product with Serializable
- final case class ReadParam extends Product with Serializable
- final case class ReadWrite[T](path: String)(implicit evidence$4: HeaderCodec[T], evidence$5: Coder[T]) extends ScioIO[T] with Product with Serializable
- final case class Write[T](path: String)(implicit evidence$3: HeaderEncoder[T]) extends ScioIO[T] with Product with Serializable
- final case class WriteParam extends Product with Serializable
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val DefaultCsvConfiguration: CsvConfiguration
- val DefaultReadParams: ReadParam
- val DefaultWriteParams: WriteParam
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- object ReadParam extends Serializable
- object WriteParam extends Serializable