put_file() Scala 中的函数?

put_file() function in Scala?

是否有与 R/Python put_file() 方法等效的方法用于从 DSX 中的 Scala 笔记本中获取对象并将其保存为项目的数据资产?如果有,有文档吗?寻找类似本文概述的内容:
https://datascience.ibm.com/blog/working-with-object-storage-in-data-science-experience-python-edition/
我已经把我要的csv文件写在notebook里面了,只需要保存到project中即可!

尝试以下步骤和代码片段 -

第 1 步:首先生成凭据。您应该能够通过单击(对于已从浏览器上传的任何文件)DSX 'File and Add Data' 窗格的文件选项卡中的 'Insert to Code->Insert Spark Session Dataframe' 来生成它。

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 步中生成凭据,并可以使用它来保存当前笔记本中的任何数据帧,甚至无需从任何文件中读取数据。