Skip to main content
Solved

How to get component values from a view with PyCelonis

  • January 9, 2025
  • 25 replies
  • 239 views

andres.naran12
Level 8
Forum|alt.badge.img+10

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!

Best answer by matt.witty13

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.

25 replies

manuel.wetze
Level 9
Forum|alt.badge.img+8
  • Level 9
  • 53 replies
  • January 10, 2025

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.


andres.naran12
Level 8
Forum|alt.badge.img+10
  • Author
  • Level 8
  • 31 replies
  • January 10, 2025

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.


matt.witty13
Level 10
  • Level 10
  • 123 replies
  • January 13, 2025

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?


andres.naran12
Level 8
Forum|alt.badge.img+10
  • Author
  • Level 8
  • 31 replies
  • January 13, 2025

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.


matt.witty13
Level 10
  • Level 10
  • 123 replies
  • January 13, 2025

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?


andres.naran12
Level 8
Forum|alt.badge.img+10
  • Author
  • Level 8
  • 31 replies
  • January 13, 2025

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.
 


matt.witty13
Level 10
  • Level 10
  • 123 replies
  • January 13, 2025

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


andres.naran12
Level 8
Forum|alt.badge.img+10
  • Author
  • Level 8
  • 31 replies
  • January 13, 2025

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.

 


matt.witty13
Level 10
  • Level 10
  • 123 replies
  • Answer
  • January 13, 2025

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.


andres.naran12
Level 8
Forum|alt.badge.img+10
  • Author
  • Level 8
  • 31 replies
  • January 13, 2025

That should work if the variables exists in the knowledge model, but In this case the variables exists only inside the views.

 

 


matt.witty13
Level 10
  • Level 10
  • 123 replies
  • January 13, 2025

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


andres.naran12
Level 8
Forum|alt.badge.img+10
  • Author
  • Level 8
  • 31 replies
  • January 13, 2025

Thanks! I think that might work. I follow your example, but I have this error:

 

 

I’m not really sure what I missing.


matt.witty13
Level 10
  • Level 10
  • 123 replies
  • January 13, 2025

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


andres.naran12
Level 8
Forum|alt.badge.img+10
  • Author
  • Level 8
  • 31 replies
  • January 13, 2025

yeah, is wear.. I’m not really sure about the issue, I just running all again but I have the same error.

 


andres.naran12
Level 8
Forum|alt.badge.img+10
  • Author
  • Level 8
  • 31 replies
  • January 14, 2025

I was able to make a few changes with part of your solution and it is working!

 

Thanks.


matt.witty13
Level 10
  • Level 10
  • 123 replies
  • January 14, 2025

Amazing! Yeah any content you’re accessing from Studio in PyCelonis is almost always a JSON Dictionary. Glad I could help!


jan.tran
Level 7
Forum|alt.badge.img+2
  • Level 7
  • 11 replies
  • August 5, 2025

@andres.naran12 

can you please share your solution?

I am also interested in extracting the view variables via MLWB.

Best regards and many thanks in advance

Jan 


janpeter.van.d
Level 12
Forum|alt.badge.img+26
  • Level 12
  • 496 replies
  • August 6, 2025

Hi ​@andres.naran12 , 

PyCelonis has a function ‘serialized content’ for views that shows you the content of a view directly: https://celonis.github.io/pycelonis/2.12.0/reference/pycelonis/ems/studio/content_node/view/#pycelonis.ems.studio.content_node.view.View.serialized_content
 


 


jan.tran
Level 7
Forum|alt.badge.img+2
  • Level 7
  • 11 replies
  • August 7, 2025

Hi ​@janpeter.van.d ,

I’ve already tried to apply “serialized_content” to the view object and I expected to get the variables.

In fact, it extracts the YAML but somehow, the view variables (also knowledge model variables) are not being displayed in the YAML.

Is your code snippet refering to a legacy view or to the current view experience with the enhanced variables?

Best regards and thank you in advance

Jan 


janpeter.van.d
Level 12
Forum|alt.badge.img+26
  • Level 12
  • 496 replies
  • August 7, 2025

@jan.tran

Fair point, this is a legacy view. We had the same issue with the enhanced variables of the Knowledge Model, that could not be easily captured (not sure if they can at this moment). 


jan.tran
Level 7
Forum|alt.badge.img+2
  • Level 7
  • 11 replies
  • August 7, 2025

@janpeter.van.d , 

this would be a a good feature request.

This is the reason why I am interested in ​@andres.naran12  solution. Could you please provide it to us?

Best regards

Jan 


andres.naran12
Level 8
Forum|alt.badge.img+10
  • Author
  • Level 8
  • 31 replies
  • August 8, 2025

Hi ​@jan.tran  what I did to get the variable’s values is the following:

variables = package.get_variables() → This allows to get the package variables.

 print(variables) → This allows me to verify that I’m getting the variables.

 

And this is a way to validate each value contained in those variables, in this case, I have 2 variables (horas, valor):


for v in variables:
    if 'horas' in v.key or 'valor' in v.value:
         print(v.key)
         print(v.value)
         data.append((v.key, v.value))
 

I hope this help.

 

Best!


jan.tran
Level 7
Forum|alt.badge.img+2
  • Level 7
  • 11 replies
  • August 8, 2025

Hi ​@andres.naran12 ,

ah - I understood. This is clever!

So you are using the runtime variables within the whole package in order to extract them.

Were you able not only to extract them but also to change / rewrite them?

Best regards and many thanks in advance

Jan 


andres.naran12
Level 8
Forum|alt.badge.img+10
  • Author
  • Level 8
  • 31 replies
  • August 8, 2025

I was only able to extract them. If you want to change them internally inside Python, maybe you can try to use pandas to update those variables. However, if you’re planning to send those variables to a data pool, you might try to create a query to update those values.

 

 


janpeter.van.d
Level 12
Forum|alt.badge.img+26
  • Level 12
  • 496 replies
  • August 18, 2025

Hi ​@jan.tran  what I did to get the variable’s values is the following:

variables = package.get_variables() → This allows to get the package variables.

 print(variables) → This allows me to verify that I’m getting the variables.

 

And this is a way to validate each value contained in those variables, in this case, I have 2 variables (horas, valor):


for v in variables:
    if 'horas' in v.key or 'valor' in v.value:
         print(v.key)
         print(v.value)
         data.append((v.key, v.value))
 

I hope this help.

 

Best!



In the newest docs, I see indeed this new Package Variables described.
You should be able to adjust the value of this variable. When running the ‘Update’ function, this should be synced with your Celonis Environment, just as it works for the legacy View Variable Updates.