Ich benutze Spark 1.6.0 und Scala.Wie kann ein Datenrahmen als komprimierte (gezippte) CSV-Datei gespeichert werden?
Ich möchte einen DataFrame als komprimiertes CSV-Format speichern. Hier
ist, was ich bisher haben (davon ausgehen, ich habe schon df
und sc
als SparkContext
):
//set the conf to the codec I want
sc.getConf.set("spark.hadoop.mapred.output.compress", "true")
sc.getConf.set("spark.hadoop.mapred.output.compression.codec", "true")
sc.getConf.set("spark.hadoop.mapred.output.compression.codec", "org.apache.hadoop.io.compress.GzipCodec")
sc.getConf.set("spark.hadoop.mapred.output.compression.type", "BLOCK")
df.write
.format("com.databricks.spark.csv")
.save(my_directory)
Der Ausgang nicht in gz
Format ist.
In Verbindung stehende Frage über RDDs: http://stackoverflow.com/questions/32231650/spark-rdd-saveastextfile-gzip –