Add an automatic timestamp to a dataset name

HL
HL Registered Posts: 7 ✭✭✭

Hello !

I would like to automatically add a timestamp to my output dataset names (and then export them to folders). Does someone know how to do that ? For example, at September, 10th, my dataset would be named "Dataset_100924"

Answers

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

    It will be better if you follow the same thread when you post questions and give all your requirements at once. Based on your prior post (see below) you want to have your file names with dynamic names like dates. This can not be done with visual recipes so you will need a Python recipe. Below is a Python recipe that will export dataset1 as dataset1_2024-09-10.csv to a managed folder. You can add as many datasets as you want to the recipe, and it will export them all.

    import dataiku
    import pandas as pd, numpy as np
    from dataiku import pandasutils as pdu
    import time
    
    # Read recipe inputs
    input_dataset1 = dataiku.Dataset("dataset1")
    input_dataset1_df = input_dataset1.get_dataframe()
    
    # Recipe outputs
    folder = dataiku.Folder("Export_Folder")
    
    current_date = time.strftime("%Y-%m-%d")
    
    folder.upload_stream("dataset1_" + current_date + ".csv", input_dataset1_df.to_csv(index=False))
    
    

Setup Info
    Tags
      Help me…