Skip to main content

Hello all,

 

How can I output the data model with a python command in the pycelonis package?

 

in pycelonis 2.0.0

this was done with the functions

pool = celonis.pools.find('my_datapool')

dm = pool.datamodels.find('my_datamodel')

 

In pycelonis 2.0.1 this doesn't seem to work anymore.

I get the data pool via:

pool = celonis.data_integration.get_data_pool(celonis_pool_id)

 

but how do I get the data models and the tables they contain?

 

Many greetings

Christoph

I think it is pool.get_data_models()

Probably it will be a list of data_model objects, so with find() you can get a specific one

 

https://celonis.github.io/pycelonis/2.0.1/reference/pycelonis/ems/data_integration/data_pool/#pycelonis.ems.data_integration.data_pool.DataPool.get_data_models

 

HTH


Hi,

You can iterate the collection of object. Below is the code snippet

 

Hope that helps.

 

Thanks,

Rio

 

image 


Hello,

 

Thank you very much for your answers.

If I type the following code into the ML in my Jupiter notebook.

 

pool = celonis.data_integration.get_data_pool(celonis_pool_id)

pool

data_model = pool.get_data_model('5fa07b36-19d0-4d67-8f88-933e2cf34a6b')

data_model

tables = data_model.get_tables()

tables

table = tables.find('15Min_ZR')

df = pd.DataFrame(table)

df

 

I get this output

image 

But what I want is not the metadata of the table. I want to output the content of the table 15Min_ZR as a data frame


Hello,

 

Thank you very much for your answers.

If I type the following code into the ML in my Jupiter notebook.

 

pool = celonis.data_integration.get_data_pool(celonis_pool_id)

pool

data_model = pool.get_data_model('5fa07b36-19d0-4d67-8f88-933e2cf34a6b')

data_model

tables = data_model.get_tables()

tables

table = tables.find('15Min_ZR')

df = pd.DataFrame(table)

df

 

I get this output

image 

But what I want is not the metadata of the table. I want to output the content of the table 15Min_ZR as a data frame

You need to use PQL() to query the table.

 

For example (in pycelonis 1.7 and dmtemp is your data model object):

 

from pycelonis.celonis_api.pql.pql import PQLColumn

from pycelonis.celonis_api.pql.pql import PQL, PQLFilter

 

query=PQL()

tablename=start_table_name

for c in dmtemp.tables.find(tablename).columns:

  c_name=c 'name']

  qval='"%s"."%s"' %(tablename,c_name)

  column=PQLColumn(query=qval, name = c_name)

  query.add(column)

 

df_final=dmtemp.get_data_frame(query)

 

df_final will contain a data frame with all the records and columns.

 

 


Hi, as mentioned by Gost, you need to create a PQL in order to perform the query in the data model. adjusted your code and added relevant code to extract data from table, check below.

 

image


Hi, as mentioned by Gost, you need to create a PQL in order to perform the query in the data model. adjusted your code and added relevant code to extract data from table, check below.

 

image

Hi Rio,

when tried to convert the table from data model to data frame, getting error as shown below.

image 

Also checked with data_model._get_data_frame(query). getting error as "Exception: Export failed.

".


Hi Sree, what is your pycelonis version. if you are using v2.0.1 export_data_frame should work.

 

https://celonis.github.io/pycelonis/2.0.1/reference/pycelonis/ems/data_integration/data_model/#pycelonis.ems.data_integration.data_model.DataModel.add_table

 

I tried my code above and it works fine.

 

Thank you,


Thanks Rio. Will update the version and run the code


Thanks Rio,

pycelonis is working with your code.


Hey ecereybody,

I have antoher Problem with jupyter.

It seems, that jupyter can´t find the directory from the "Oracle Instand Client".

Same code works in PyCharm when the directory from the instand client is on a local disk.

Screenshot1Screenshot2Screenshot3 


2 possible reasons ...

 

  • If you are running that jupyter from the ML Workbench, remember that is a Linux and the path separator is "/" and not "\\" as in Windows
  • If you are in windows, the libdir refers to a directory instanclient that is in the disk root... judging by your screenshot of the tree, I think "instantclient_21_9" will work, as the invoking jupyter seems to be in the same path as that directory

 

 

HTH


Reply