Skip to contents

Save the content of the SparkDataFrame in a text file at the specified path. The SparkDataFrame must have only one column of string type with the name "value". Each row becomes a new line in the output file. The text files will be encoded as UTF-8.

Usage

write.text(x, path, ...)

# S4 method for SparkDataFrame,character
write.text(x, path, mode = "error", ...)

Arguments

x

A SparkDataFrame

path

The directory where the file is saved

...

additional argument(s) passed to the method. You can find the text-specific options for writing text files in https://spark.apache.org/docs/latest/sql-data-sources-text.html#data-source-optionData Source Option in the version you use.

mode

one of 'append', 'overwrite', 'error', 'errorifexists', 'ignore' save mode (it is 'error' by default)

Note

write.text since 2.0.0

Examples

if (FALSE) {
sparkR.session()
path <- "path/to/file.txt"
df <- read.text(path)
write.text(df, "/tmp/sparkr-tmp/")
}