0 votes
I'm using an "export to folder" recipe to create a CSV that can then be used by other components. I'd like the CSVs to be named depending on the day they are exported :

- export_2017-01-25.csv
- export_2017-01-26.csv
- export_2017-01-27.csv

How can I do so ?
asked by
retagged by

1 Answer

+2 votes
Best answer

One way of doing this is by using a python recipe on the dataset you wish to export, with a folder as output. In the recipe you can use the following code:

# -*- coding: utf-8 -*-
import dataiku
import pandas as pd, numpy as np
from dataiku import pandasutils as pdu

# Recipe inputs
input_dataset_name = dataiku.Dataset("input_dataset_name")
input_dataset_name_df = input_dataset_name.get_dataframe()

# Recipe outputs
folder_name = dataiku.Folder("folder_id")
folder_name_path = folder_name.get_path()

import time
current_day = time.strftime("%Y-%m-%d")
input_dataset_name_df.to_csv(path_or_buf=folder_name_path+"export_"+current_day+".csv", index=False)

 

Note that the first lines (input dataset, output folder etc) are all generated by DSS. So you should only add the last 3 lines of this code to your recipe, and change "input_dataset_name_df" and "folder_name_path" with the proper name.

 

answered by
selected by
562 questions
574 answers
419 comments
320 users