Я даю ответ в scala, но в python также это основные шаги ..
import org.apache.hadoop.fs.{FileSystem, Path}
val fs: FileSystem = FileSystem.get(spark.sparkContext.hadoopConfiguration);
val file = fs.globStatus(new Path("data/jsonexample/part*"))(0).getPath().getName()
println("file name " + file)
fs.rename(
new Path("data/jsonexample/" + file)
, new Path("data/jsonexample/tsuresh97_json_toberenamed.json"))
Полный пример:
import spark.implicits._
val df = Seq(
(123, "ITA", 1475600500, 18.0),
(123, "ITA", 1475600500, 18.0),
(123, "ITA", 1475600516, 19.0)
).toDF("Value", "Country", "Timestamp", "Sum")
df.coalesce(1)
.write
.mode(SaveMode.Overwrite)
.json("data/jsonexample/")
import org.apache.hadoop.fs.{FileSystem, Path}
val fs: FileSystem = FileSystem.get(spark.sparkContext.hadoopConfiguration);
val file = fs.globStatus(new Path("data/jsonexample/part*"))(0).getPath().getName()
println("file name " + file)
fs.rename(
new Path("data/jsonexample/" + file)
, new Path("data/jsonexample/tsuresh97_json_toberenamed.json"))
Результат:
json содержание:
{"Value":123,"Country":"ITA","Timestamp":1475600500,"Sum":18.0}
{"Value":123,"Country":"ITA","Timestamp":1475600500,"Sum":18.0}
{"Value":123,"Country":"ITA","Timestamp":1475600516,"Sum":19.0}