python recipe output to a dataset

ltounsi
ltounsi Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 3

hello i have a list containing items as data frame type i want to make an output to this output as text file or json file if any one can help me please

Tagged:

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,141 Neuron

    It really depends what you want to do with the file after. Is this a one off export? Why do you need the output as a file? Can you explain your requirement in detail?

  • ltounsi
    ltounsi Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 3

    hello @Turribeach
    yes please if you can help me

    i want to have as output multiple dataframes in a managed folder if you can please help me

    regards

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,141 Neuron
    edited July 17

    The following Python code in a Python recipe will output the contents of the df dataframe to a CSV file:

    import dataiku
    
    path_upload_file = "output.csv"
    handle = dataiku.Folder("Some Managed Folder")
    
    with handle.get_writer(path_upload_file) as w:
        w.write(df.to_csv().encode('utf-8'))
Setup Info
    Tags
      Help me…