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")
)
0.14.8-23-c45685a-20241105T161920Z*