嘗試下面的步驟和代碼片段 -
步驟1:首先產生的憑證。您應該可以通過單擊(對於已從瀏覽器上載的任何文件)從DSX中的「文件和添加數據」窗格的「文件」選項卡中的「插入到代碼 - >插入Spark會話數據框」來生成它。
def setHadoopConfig2db1c1ff193345c28eaffb250b92d92b(name: String) = {
val prefix = "fs.swift.service." + name
sc.hadoopConfiguration.set(prefix + ".auth.url", "https://identity.open.softlayer.com" + "/v3/auth/tokens")
sc.hadoopConfiguration.set(prefix + ".auth.endpoint.prefix","endpoints")
sc.hadoopConfiguration.set(prefix + ".tenant", "<tenant id>")
sc.hadoopConfiguration.set(prefix + ".username", "<userid>")
sc.hadoopConfiguration.set(prefix + ".password", "<password.")
sc.hadoopConfiguration.setInt(prefix + ".http.port", 8080)
sc.hadoopConfiguration.set(prefix + ".region", "dallas")
sc.hadoopConfiguration.setBoolean(prefix + ".public", false)
}
val name = "keystone"
setHadoopConfig2db1c1ff193345c28eaffb250b92d92b(name)
val data_frame1 = spark.read.option("header","true").csv("swift://'Your
DSXProjectName'.keystone/<your file name>.csv")
第2步:一些代碼,創建從data_frame1 data_frame2說,一些改造後
步驟3:而在對象存儲節省data_frame2數據到文件中使用相同的容器和項目名稱
data_frame2.write.option("header","true").csv("swift://'Same DSXproject name as before'.keystone/<name of the file u want to write the data>.csv")
請注意,您可以在步驟1中生成憑證,並且可以使用它來保存當前筆記本中的任何數據框,而無需從任何文件讀取數據。
您是否試圖將DSX中的spark數據框保存爲scala中的對象存儲? 如果是,則爲spark 2.0語法 spark.write.csv() –