Data Model: Pull data¶
In [1]:
Copied!
#To get a copy of this notebook in your current working dirtectory, run:
from pycelonis.notebooks import api_tutorial
#To get a copy of this notebook in your current working dirtectory, run:
from pycelonis.notebooks import api_tutorial
1. Connect to Celonis¶
In [2]:
Copied!
from pycelonis import get_celonis
celonis = get_celonis()
from pycelonis import get_celonis
celonis = get_celonis()
2. Connect to an Data Model in Celonis¶
find the data model by either searching for the name or ID.
In [3]:
Copied!
datamodel = celonis.datamodels.find('440cb0ba-7f00-4ec9-a50a-f9f8772e5893')
datamodel
datamodel = celonis.datamodels.find('440cb0ba-7f00-4ec9-a50a-f9f8772e5893')
datamodel
3. Write the Query¶
Write a pql query just as you would in an analysis
In [4]:
Copied!
from pycelonis import pql
q = pql.PQL()
q += pql.PQLColumn("ACTIVIT_TABLE.ACTIVITY_EN", "Activity Name")
q += pql.PQLFilter("Filter ACTIVIT_TABLE.ACTIVITY_EN != 'Create Case'; ")
from pycelonis import pql
q = pql.PQL()
q += pql.PQLColumn("ACTIVIT_TABLE.ACTIVITY_EN", "Activity Name")
q += pql.PQLFilter("Filter ACTIVIT_TABLE.ACTIVITY_EN != 'Create Case'; ")
4.1 Extract the data without chunking¶
Extract the OLAP table with the get_data_frame() function on datamodel without chunking it. This can be done for table of size < 1 GB.
In [5]:
Copied!
df = datamodel.get_data_frame(q)
df.head()
df = datamodel.get_data_frame(q)
df.head()
Note: In new teams, data export is not enabled by default. To enable it contact Celonis customer support.^
4.2 Advanced: Chunk the data by the rows¶
If the table you want to extract is bigger than 1 GB, the export will fail without chunking. To apply chunking you currently need Process Analytics Permissions to create and delete workspaces and analyses. If you have these permissions you can specify the number of rows per chunk via the chunksize parameter.
In [6]:
Copied!
df = datamodel.get_data_frame(q, chunksize=10000)
df.head()
df = datamodel.get_data_frame(q, chunksize=10000)
df.head()