Using value of column (of a dataset) in email body

Solved!
pafj
Level 3
Using value of column (of a dataset) in email body

Hi Dataiku community,

 I am attaching a dataset in an email notification after scenario ends as an excel file. 

In the email body, how can I use a value of a column (which is date)? There are many records in the dataset but the value of one column is the same across the table and showing a date.

Thanks

0 Kudos
1 Solution
JordanB
Dataiker

Hi @pafj,

There may be a few ways to do this; I've created a custom python step in a scenario that converts a dataset into a data frame, converts a timestamp to a string and replaces the current variable "date" with the first value in column "time_start". Note, you will need to create the global variable in your project first and the script below will update it. 

 

import dataiku
from dataiku import pandasutils as pdu
import pandas as pd

client = dataiku.api_client()
project = client.get_project("project-key")

mydataset = dataiku.Dataset("dataset")
df = mydataset.get_dataframe()

df['time_start'] = df['time_start'].astype(str)
var = df['time_start'][0]

#the variable must be created first
variables = project.get_variables()
variables["standard"]["date"] = var
project.set_variables(variables)

 

 

Please let me know if you have any questions.

Thanks,

Jordan

View solution in original post

0 Kudos
4 Replies
JordanB
Dataiker

Hi @pafj,

There may be a few ways to do this; I've created a custom python step in a scenario that converts a dataset into a data frame, converts a timestamp to a string and replaces the current variable "date" with the first value in column "time_start". Note, you will need to create the global variable in your project first and the script below will update it. 

 

import dataiku
from dataiku import pandasutils as pdu
import pandas as pd

client = dataiku.api_client()
project = client.get_project("project-key")

mydataset = dataiku.Dataset("dataset")
df = mydataset.get_dataframe()

df['time_start'] = df['time_start'].astype(str)
var = df['time_start'][0]

#the variable must be created first
variables = project.get_variables()
variables["standard"]["date"] = var
project.set_variables(variables)

 

 

Please let me know if you have any questions.

Thanks,

Jordan

0 Kudos
pafj
Level 3
Author

Hi @JordanB 

Thank you for taking the time and replying to my question.

I am pretty new to dataiku and I was wondering if you could direct me how to create a Global Variable in my project?

Thanks

0 Kudos
CoreyS
Dataiker Alumni

Hi @pafj while you wait for Jordan's reply here are a few resources to get you started:

I hope this helps!

Looking for more resources to help you use Dataiku effectively and upskill your knowledge? Check out these great resources: Dataiku Academy | Documentation | Knowledge Base

A reply answered your question? Mark as โ€˜Accepted Solutionโ€™ to help others like you!
0 Kudos
JordanB
Dataiker

Hi @pafj,

Corey has provided the documentation. You can navigate to your project variables from within the project menu. Variables should be in json format (as shown below).

Screen Shot 2022-10-28 at 3.07.13 PM.png

Screen Shot 2022-10-28 at 3.08.39 PM.png

Please let us know if you have any further questions.

Thanks!

โ€ƒ

0 Kudos