package csv
Main package for CSV type-safe APIs. Import all.
import com.spotify.scio.extra.csv._
- Source
- package.scala
- Alphabetic
- By Inheritance
- csv
- AllSyntax
- ScioContextSyntax
- SCollectionSyntax
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
Type Members
- implicit final class ReadableCsvFileSCollection extends AnyRef
- Definition Classes
- SCollectionSyntax
- implicit final class WritableCsvSCollection[T] extends AnyRef
- Definition Classes
- SCollectionSyntax
- implicit final class CsvScioContext extends AnyRef
- Definition Classes
- ScioContextSyntax
Value Members
- object CsvIO
This package uses a CSV mapper called Kantan.
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)