Writing a R Dataframe into CSV in non-local Managedfolder in Dataiku

lucifer20 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 4
edited July 16 in Using Dataiku

I want to write a R dataframe in csv format in a non-local managed folder. I am not getting how to do this. I tried the method mentioned in Dataiku documentation but it is not giving desired results.

From Documenttaion:

# data must be a connection providing the data to upload
dkuManagedFolderUploadPath("folder_name", "path_in_folder", data)

It says that data should be a connection. I tried with below code but it is creating a binary file and csv.

save(df, file= "sample.csv")
connection <- file("sample.csv", "rb")
dkuManagedFolderUploadPath("folderid", "sample.csv", connection)

Please help.


  • Catalina
    Catalina Dataiker, Dataiku DSS Core Designer, Registered Posts: 135 Dataiker
    edited July 17

    Hi @lucifer20

    To save a dataframe to a CSV file you can use write.csv(). Below is an example code:

    # Read the dataset as a dataframe
    input_df <- dkuReadDataset("input")
    # Export the dataframe to a temporary local CSV file
    tmp_csv_path <- tempfile()
    write.csv(input_df, tmp_csv_path)
    # Open the CSV file for reading (as a R "connection")
    tmp_csv_file_connection <- file(tmp_csv_path, "rb")
    # Push the result to the managed folder
    dkuManagedFolderUploadPath("folderid", "mydataset.csv", tmp_csv_file_connection)
    # Close the connection
    # Delete the temporary file

Setup Info
      Help me…