Text

Reading text

Scio reads newline-delimited text via textFile:

import com.spotify.scio._
import com.spotify.scio.avro._
import com.spotify.scio.values.SCollection

val sc: ScioContext = ???
val elements: SCollection[String] = sc.textFile("gs://<input-path>/*.txt")

Writing text

An SCollection[String] or SCollection of any class implementing toString can be written out to a newline-delimited text file via saveAsTextFile. An optional header and footer parameter can be provided.

import com.spotify.scio._
import com.spotify.scio.avro._
import com.spotify.scio.values.SCollection

val elements: SCollection[String] = ???
elements.saveAsTextFile(
  "gs://<output-path>", 
  header=Some("header"), 
  footer=Some("footer")
)