Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
I would like to have a project variable that is a list. How is that done? To be clear, I'd like a list such as:
"list": "['a','b','c']"
I thought that this would work given that Json interprets this as a strong. I get an error:
Error in Python process: At line 84: <class 'KeyError'>: ['asd', 'def']
I have not found a combination that worked. My Python code is:
vars = Dataiku.get_custom_variables()
print("keep_cols: ", keep_cols)
Thanks for any insights.
Operating system used: Mac, Ventura
Hi @Erlebacher,
You can load a project variable that's a list in Python by using json.loads()
For example, if I have a project variable that looks like this:
{
"keep_cols": ["a", "b", "c"]
}
I can load it using the following code:
import json
import dataiku
vars = dataiku.get_custom_variables()
keep_cols = json.loads(vars["keep_cols"])
print("keep_cols: ", keep_cols)
Thanks,
Zach
Hi @Erlebacher,
You can load a project variable that's a list in Python by using json.loads()
For example, if I have a project variable that looks like this:
{
"keep_cols": ["a", "b", "c"]
}
I can load it using the following code:
import json
import dataiku
vars = dataiku.get_custom_variables()
keep_cols = json.loads(vars["keep_cols"])
print("keep_cols: ", keep_cols)
Thanks,
Zach