Dataiku App - Download dataset

Options
Aastha
Aastha Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 4

Hi,

I have 2 questions on download of dataset as part of dataiku app:

1. Is it possible to download the dataset in JSON format? I don't see the option in dropdown file type options.

2. If we download as csv, is it possible to customize the downloaded file name like add the download date, or change downloaded file name automatically?

Thanks,

Aastha

Answers

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,209 Dataiker
    edited July 17
    Options

    Hi Aastha,

    Exporting as JSON is not supported.
    You can copy a row from explore as json. This is useful for testing API queries to Prediction API endpoints.
    You can use a Python recipe and write the JSON to a managed folded and then download the managed by browsing that folder.


    import dataiku
    import pandas as pd
    import numpy as np
    from dataiku import pandasutils as pdu
    from datetime import datetime
    
    # Read recipe inputs
    ticket_search_csv = dataiku.Dataset("dataset_name")
    ticket_search_csv_df = ticket_search_csv.get_dataframe()
    output_folder = dataiku.Folder("B9rFvU0O")
    output_folder_info = csm_json.get_info()
    
    # Get the current date and time
    current_date_time = datetime.now()
    
    # Format the date as YYYY-MM-DD-HH
    date_formatted = current_date_time.strftime("%Y-%m-%d-%H")
    
    # Create the filename with the formatted date
    filename = f"filename_prefix_{date_formatted}.json"
    
    #for local folders for remote folders S3 see get_writer/ upload_stream https://knowledge.dataiku.com/latest/code/managed-folders/tutorial-managed-folders.html
    path = output_folder.get_path()
    
    # Save the DataFrame to a JSON file with the updated filename
    ticket_search_csv_df.to_json(path + "/" + filename, orient="records"

Setup Info
    Tags
      Help me…