Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Is there a way I can take a file (.csv or .xlsx) from a folder in DSS and send it to a local folder using Python?
Operating system used: Windows
Hi @Pete1 ,
Below is an example Python code that uses Dataiku Python APIs to export the files from a DSS folder to a local folder called output :
import dataikuapi
import io, os
host="http://localhost:11200"
apiKey = "*******"
project_key="******"
folder_id="*****"
def api_py_function(project_key, folder_id):
client = dataikuapi.DSSClient(host,apiKey)
folder = dataikuapi.dss.managedfolder.DSSManagedFolder(client, project_key, folder_id)
contents = folder.list_contents()
if not os.path.exists("output"):
os.mkdir("output")
for item in contents["items"]:
with open("output/"+item["path"], "wb") as f:
file = folder.get_file(item["path"])
f.write(file.content) โ
api_py_function(project_key,folder_id)
Hi @Pete1 ,
Below is an example Python code that uses Dataiku Python APIs to export the files from a DSS folder to a local folder called output :
import dataikuapi
import io, os
host="http://localhost:11200"
apiKey = "*******"
project_key="******"
folder_id="*****"
def api_py_function(project_key, folder_id):
client = dataikuapi.DSSClient(host,apiKey)
folder = dataikuapi.dss.managedfolder.DSSManagedFolder(client, project_key, folder_id)
contents = folder.list_contents()
if not os.path.exists("output"):
os.mkdir("output")
for item in contents["items"]:
with open("output/"+item["path"], "wb") as f:
file = folder.get_file(item["path"])
f.write(file.content) โ
api_py_function(project_key,folder_id)