Pulling data

[ ]:
#To get a copy of this notebook in your current working dirtectory, run:
from pycelonis import notebooks

This tutorial shows how data from an OLAP table in Celonis can be extracted. The data can then be used in Python. To do this, only 4 steps are necessary: 1. Connect to Celonis 2. Connect to an analysis in Celonis that contains the OLAP table 3. Find the OLAP table 4. Extract the OLAP table

Connect to Celonis …

[1]:
from pycelonis import get_celonis

celonis = get_celonis()
2019-12-04 08:23:17 - pycelonis: Login successful! Hello Simon Riezebos

… and find the analysis by either searching for the analysis’s name or ID

[2]:
analysis = celonis.analyses.find('440cb0ba-7f00-4ec9-a50a-f9f8772e5893')
analysis
[2]:
<Analysis, id 440cb0ba-7f00-4ec9-a50a-f9f8772e5893, name Test PyCelonis>

Find the table that you want to extract through the table’s name.

[3]:
component = analysis.draft.components.find("Vendors")
component
2019-12-04 08:23:24 - pycelonis: Best matches: [(0.9, '#{Vendors}'), (0.4, 'No. of vendors'), (0.0, '')]
[3]:
<BaseAnalysisComponent, id 6bce2ff5-ee25-4d59-8387-81c387a8fc30, name #{Vendors}>

Extract the OLAP table with the the get_data_frame() function.

[4]:
df = component.get_data_frame()
df.head()
[4]:
LFA1.LIFNR LFA1.LAND1
0 SORAYA45 ES
1 SP-CARA IT
2 SP-CARB IT
3 SRV-2 DE
4 SS_FLEET1 US

Advanced: Add filters and variables from “Share your selections”

image.png

Make a selection and/or change variables and copy the url into the cell below

[6]:
url = "https://ml-appstore.eu-1.celonis.cloud/process-mining/analysis/440cb0ba-7f00-4ec9-a50a-f9f8772e5893/link/frontend/documents/440cb0ba-7f00-4ec9-a50a-f9f8772e5893/view/sheets/5066b16f-f342-4be4-a70c-b744684e5ac3/b/0dd91c45-73c2-4312-93c5-d7602bcc640b"
selection = analysis.process_shared_selection_url(url)

Add the selection query to the component query and pull the data from the analysis

[7]:
query = component.pql_query
query += selection
analysis.get_data_frame(query)
[7]:
LFA1.LIFNR LFA1.LAND1
0 SORAYA45 ES
1 SP-CARA IT
2 SP-CARB IT