How to get component values from a view with PyCelonis
Hi everyone I have a challenge that I’m trying to figure out related to pycelonis.
I’m currently trying to get the component values from a view using pycelonis. Unfortunately, I couldn’t find any information inside the documentation that can help me with this.
It seems that the documentation only explains how to work with analysis or knowledge models. Does anyone know how to work with components of a view inside pycelonis?
Best wishes!
Page 1 / 1
Hi andres, why can’t you just use the knowledge model which is attached to the view?
I know that with the latest updates you could technically have KPIs or dimensions only in the view without KM, but if you want to access the data from view & PyCelonis they seem important enough and you should maintain and store them centrally in a KM anyway in my opinion.
My assumption would be that PyCelonis only supports the documented ways as analysis & KM.
Hi Manuel, in this case, I need to get the custom values that the customer inserts in a view.
This view doesn’t use any dimension from the knowledge model or take any data from the data model since the component values are completely customized by the user. What we need is to extract those values and sending back to the data pool where they will be stored in order to have a historical record from all values that the client insert.
With this historical record we need to create some transformations that can be use to new analysis or views inside studio. Reading the pycelonis documentation explain that you can retrieve values from views, but I couldn't find any explanation that show how to do that.
Are you saying the values are augmented attributes? If that’s the case you can pull those.
What do you mean by they are custom values inserted by the customer?
Not the values are not augmented attributes in that case I could use an action flow that allows me to get those values. But in this scenario with are working a view that use variables which store the values inserted by the customers.
Unfortunately the action flow is not able to get variable’s values, for that reason I’m looking for another approach with PyCelonis.
I guess I’m confused then. Are they comments? There should be a way to access these values within PyCelonis. Can you provide a screenshot?
Yes, they are values that the client types, and these values are stored in variables that are being used for other KPIs. Attached is an example:
I need to get the value from each component for each tab in this view and send those values to the data pool.
Okay can you show the code/YAML behind those components? If they’re truly variables, you should be able to pull those values into PyCelonis
This is a brief code/YAML behind one component, as you can see in the code there’re truly variables. The PyCelonis documentation explains how to get the views published, but doesn’t explain how to read the component values for views.
I tried to replicate the steps to get the components' values but only works for analyses, but not for views.
Okay okay okay I see.
You’re going to want to go through get_knowledge_model().
You then have get_variables(). That’ll give you all the variables in the knowledge model.
From there, variable objects in Python have different functions you can call. Call “display_name” and “value” and you’ll get how the variable looks on the front end and then the current value stored in the variables, as you see in the screenshot above.
That should work if the variables exists in the knowledge model, but In this case the variables exists only inside the views.
json_dict() is where everything lives in terms of PyCelonis assets. Load the JSON packages to be able to use the loads function. Then call ‘variables’] and it’ll give you the view variables
Thanks! I think that might work. I follow your example, but I have this error:
I’m not really sure what I missing.
That’s… odd? Try running it again? It looks like you ran the for loop after you tried the new_dict_‘variables’]. I’m not sure what is happening otherwise. But that should get you the variables you’re looking for
yeah, is wear.. I’m not really sure about the issue, I just running all again but I have the same error.
I was able to make a few changes with part of your solution and it is working!
Thanks.
Amazing! Yeah any content you’re accessing from Studio in PyCelonis is almost always a JSON Dictionary. Glad I could help!