且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如果文件已存在于 pyspark 中,如何覆盖 rdd saveAsPickleFile(path)?

更新时间:2023-12-02 18:03:28

您可以像下面这样保存 RDD 文件注意(代码在scala中,但python的逻辑也应该相同)我使用的是2.3.0 spark版本.

Hi you can save RDD files like below Note (code is in scala but logic should be same for python as well) i am using 2.3.0 spark version.

  val sconf = new SparkConf().set("spark.hadoop.validateOutputSpecs", "False").setMaster("local[*]").setAppName("test")
  val scontext = new SparkContext(sconf)
  val lines = scontext.textFile("s${filePath}", 1)
    println(lines.first)
    lines.saveAsTextFile("C:\\Users\\...\\Desktop\\sample2")

或者如果你使用 DataFrame 然后使用

or if ur working with DataFrame then use

DF.write.mode(SaveMode.Overwrite).parquet(path.parquet)

或了解更多信息,请查看 这个

or for more info please look at this