Data Upload¶
In this tutorial, you will learn how to upload existing data from your local Python project into the EMS. More specifically, you will learn:
- How to create a new table in the EMS with your data
- How to append and upsert your data to existing tables in the EMS
- How to add a table from your data pool to your data model
- How to reload a data model
Prerequisites¶
To follow this tutorial, you should have already created a data pool and a data model inside your pool. If you haven't done this yet, please complete the Data Integration - Introduction tutorial first.
Tutorial¶
1. Import PyCelonis and connect to Celonis API¶
from pycelonis import get_celonis
celonis = get_celonis(permissions=False)
[2023-06-26 13:09:52,420] INFO: No `base_url` given. Using environment variable 'CELONIS_URL' [2023-06-26 13:09:52,422] INFO: No `api_token` given. Using environment variable 'CELONIS_API_TOKEN'
[2023-06-26 13:09:52,508] WARNING: KeyType is not set. Defaulted to 'APP_KEY'.
[2023-06-26 13:09:52,510] INFO: Initial connect successful! PyCelonis Version: 2.3.0
2. Select data pool to upload data into¶
Before we can upload data into the EMS, we first have to select a data pool, into which the data should be uploaded. Here, we use the data pool, which we created in the Data Integration - Introduction tutorial:
data_pool = celonis.data_integration.get_data_pools().find("PyCelonis Tutorial Data Pool")
data_pool
DataPool(id='6c178afe-21e2-4f77-b862-e37653ae0b2e', name='PyCelonis Tutorial Data Pool')
With the get_tables()
method, we can verify that we currently don't have any tables in the data pool:
data_pool.get_tables()
[]
3. Upload data into the EMS¶
Data can be uploaded into Celonis in two formats: as Pandas dataframes or as Parquet files. In this tutorial, we will focus on pushing data as Pandas dataframes. If you want to push data as Parquet files, please refer to the Data Push & Export Advanced tutorial.
In this tutorial, we will use a sample dataset for the SAP Purchase-to-Pay (P2P) process, which depicts the process of procuring materials from vendors. Below, is an overview of the most important tables for this process:
Table | Description |
---|---|
_CEL_P2P_ACTIVITIES_EN | Activity Table |
EKPO | Purchasing Document Item (i.e. Case Table) |
EKKO | Purchasing Document Header |
LFA1 | Vendor Master Data |
Let's start by importing the tables of this dataset as Pandas dataframes:
import pandas as pd
activity_df = pd.read_parquet("../../../assets/_CEL_P2P_ACTIVITIES_EN.parquet", engine="pyarrow")
print(activity_df.shape)
activity_df.head()
(60, 13)
_CASE_KEY | ACTIVITY_EN | ACTIVITY_DE | EVENTTIME | _SORTING | USER_TYPE | CHANGED_TABLE | CHANGED_FIELD | CHANGED_FROM | CHANGED_TO | CHANGED_FROM_FLOAT | CHANGED_TO_FLOAT | CHANGE_NUMBER | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 800000000006800001 | Create Purchase Requisition Item | Lege BANF Position an | 2008-12-31 07:44:05 | 0.0 | B | None | None | None | None | NaN | NaN | None |
1 | 800000000006800001 | Create Purchase Order Item | Lege Bestellposition an | 2009-01-02 07:44:05 | 10.0 | B | None | None | None | None | NaN | NaN | None |
2 | 800000000006800001 | Print and Send Purchase Order | Sende Bestellung | 2009-01-05 07:44:05 | NaN | B | None | None | None | None | NaN | NaN | None |
3 | 800000000006800001 | Receive Goods | Wareneingang | 2009-01-12 07:44:05 | 30.0 | A | None | None | None | None | NaN | NaN | None |
4 | 800000000006800001 | Scan Invoice | Scanne Rechnung | 2009-01-20 07:44:05 | NaN | A | None | None | None | None | NaN | NaN | None |
item_df = pd.read_parquet("../../../assets/EKPO.parquet", engine="pyarrow")
print(item_df.shape)
item_df.head()
(10, 34)
_CASE_KEY | MANDT | LOEKZ | STATU | AEDAT | MATNR | BUKRS | WERKS | LGORT | MATKL | ... | AUDAT | Material Text (MAKT_MAKTX) | Company Code Text (EKPO_BUKRS) | Plant Text (EKPO_WERKS) | Stor Location Text (EKPO_LGORT) | EBELN | EBELP | Item Category Text(EKPO_PSTYP) | Material Group Text (MATKL_TEXT) | Net Value(NETWR_EUR) | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 800000000006800001 | 800 | None | None | 2009-01-02 | WL-1000 | 3000 | 3200 | 0001 | 001 | ... | NaT | Shafting assembly | IDES US INC | Atlanta | Warehouse 0001 | 0000000068 | 00001 | Standard | Metal processing | 3.48000 |
1 | 800000000006800002 | 800 | None | None | 2009-01-02 | None | 3000 | 3200 | 0001 | 00202 | ... | NaT | IDES US INC | Atlanta | Warehouse 0001 | 0000000068 | 00002 | Standard | Motherboards | 3.46260 | |
2 | 800000000006800003 | 800 | None | None | 2009-01-02 | DG-1000 | 3000 | 3200 | 0001 | 001 | ... | NaT | Rubber Seal | IDES US INC | Atlanta | Warehouse 0001 | 0000000068 | 00003 | Standard | Metal processing | 0.29000 |
3 | 800000000006800004 | 800 | None | None | 2009-01-02 | I-1100 | 3000 | 3200 | 0001 | 007 | ... | NaT | Pump Installation | IDES US INC | Atlanta | Warehouse 0001 | 0000000068 | 00004 | Standard | Services | 2.90000 |
4 | 800000000006800005 | 800 | None | None | 2009-01-02 | None | 3000 | 3200 | 0001 | 001 | ... | NaT | IDES US INC | Atlanta | Warehouse 0001 | 0000000068 | 00005 | Standard | Metal processing | 0.27608 |
5 rows × 34 columns
header_df = pd.read_parquet("../../../assets/EKKO.parquet", engine="pyarrow")
print(header_df.shape)
header_df.head()
(2, 33)
MANDT | BUKRS | BSTYP | BSART | LOEKZ | STATU | AEDAT | ERNAM | LIFNR | ZTERM | ... | FRGZU | Document Category Text (EKKO_BSTYP) | RFQ status Text(EKKO_STATU) | Document Type Text (EKKO_BSART) | Purchasing Organization Text (EKKO_EKORG) | Company Name (EKKO_BUTXT) | Country Key (EKKO_LAND1) | Currency Key (EKKO_WAERS) | EBELN | Company Code Text (EKKO_BUKRS) | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
14312 | 800 | 3000 | F | EC | None | I | 2009-01-02 | PURCHMANAGER | 0000003701 | NT30 | ... | None | Purchase order | None | Electronic commerce | IDES Deutschland | IDES US INC | US | USD | 0000000068 | IDES US INC |
14338 | 800 | 3000 | F | EC | None | I | 2009-02-03 | MILLERJ | 0000003701 | NT30 | ... | None | Purchase order | None | Electronic commerce | IDES Deutschland | IDES US INC | US | USD | 0000000069 | IDES US INC |
2 rows × 33 columns
master_df = pd.read_parquet("../../../assets/LFA1.parquet", engine="pyarrow")
print(master_df.shape)
master_df.head()
(1, 22)
MANDT | LIFNR | LAND1 | NAME1 | ORT01 | PFACH | PSTL2 | PSTLZ | REGIO | SORTL | ... | BEGRU | ERDAT | ERNAM | SPRAS | TELBX | TELF1 | TELF2 | TELFX | TELTX | TELX1 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
263 | 800 | 0000003701 | US | eSupplier, Inc | WILMINGTON | None | None | 19801 | DE | EBP | ... | None | 2001-12-07 | STANKOVICH | E | None | 302-656-0196 | None | 302-656-0001 | None | None |
1 rows × 22 columns
After having the dataframes in place, we can upload them into the EMS by either creating new tables in the data pool or by appending/upserting the data into existing tables of the data pool.
3.1 Create new table in the EMS¶
New tables can be created in the EMS with the create_table()
method. The method takes as input arguments:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame |
A pandas dataframe containing the data | Required |
table_name |
str |
Name that the table in the data pool should have | Required |
drop_if_exists |
bool |
Specifies how to handle situations when a table with the same name already exists in the data pool (True = replace existing table, False = raise error and keep existing table) | False |
Further, we can give a column_config
as input argument, which specifies the names and column types of our table. Specifying a custom column_config
is especially important if we use tables with longer text values, as by default, strings are cut off after 80 characters during the data upload. For a guide on how to specify a custom column_config
, refer to the Data Push & Export Advanced tutorial.
data_pool.create_table(df=activity_df, table_name="ACTIVITIES", drop_if_exists=False)
data_pool.create_table(df=item_df, table_name="EKPO", drop_if_exists=False)
data_pool.create_table(df=header_df, table_name="EKKO", drop_if_exists=False)
data_pool.create_table(df=master_df, table_name="LFA1", drop_if_exists=False)
[2023-06-26 13:09:52,706] WARNING: STRING columns are by default stored as VARCHAR(80) and therefore cut after 80 characters. You can specify a custom field length for each column using the `column_config` parameter.
[2023-06-26 13:09:52,710] INFO: Successfully created data push job with id '83ffb216-2be1-4a80-9412-6ce566086b2d' [2023-06-26 13:09:52,711] INFO: Add data frame as file chunks to data push job with id '83ffb216-2be1-4a80-9412-6ce566086b2d'
[2023-06-26 13:09:52,733] INFO: Successfully upserted file chunk to data push job with id '83ffb216-2be1-4a80-9412-6ce566086b2d' [2023-06-26 13:09:52,741] INFO: Successfully triggered execution for data push job with id '83ffb216-2be1-4a80-9412-6ce566086b2d' [2023-06-26 13:09:52,742] INFO: Wait for execution of data push job with id '83ffb216-2be1-4a80-9412-6ce566086b2d'
[2023-06-26 13:09:52,765] INFO: Successfully created table 'ACTIVITIES' in data pool [2023-06-26 13:09:52,769] INFO: Successfully deleted data push job with id '83ffb216-2be1-4a80-9412-6ce566086b2d'
[2023-06-26 13:09:52,777] WARNING: STRING columns are by default stored as VARCHAR(80) and therefore cut after 80 characters. You can specify a custom field length for each column using the `column_config` parameter.
[2023-06-26 13:09:52,782] INFO: Successfully created data push job with id 'c0c34d7a-22f4-41f8-bca8-261a09749ce3' [2023-06-26 13:09:52,783] INFO: Add data frame as file chunks to data push job with id 'c0c34d7a-22f4-41f8-bca8-261a09749ce3'
[2023-06-26 13:09:52,805] INFO: Successfully upserted file chunk to data push job with id 'c0c34d7a-22f4-41f8-bca8-261a09749ce3' [2023-06-26 13:09:52,816] INFO: Successfully triggered execution for data push job with id 'c0c34d7a-22f4-41f8-bca8-261a09749ce3' [2023-06-26 13:09:52,817] INFO: Wait for execution of data push job with id 'c0c34d7a-22f4-41f8-bca8-261a09749ce3'
[2023-06-26 13:09:52,841] INFO: Successfully created table 'EKPO' in data pool [2023-06-26 13:09:52,846] INFO: Successfully deleted data push job with id 'c0c34d7a-22f4-41f8-bca8-261a09749ce3'
[2023-06-26 13:09:52,856] WARNING: STRING columns are by default stored as VARCHAR(80) and therefore cut after 80 characters. You can specify a custom field length for each column using the `column_config` parameter.
[2023-06-26 13:09:52,862] INFO: Successfully created data push job with id '2a26e6b1-9c0a-4475-b4f3-c2377ae37545' [2023-06-26 13:09:52,863] INFO: Add data frame as file chunks to data push job with id '2a26e6b1-9c0a-4475-b4f3-c2377ae37545'
[2023-06-26 13:09:52,883] INFO: Successfully upserted file chunk to data push job with id '2a26e6b1-9c0a-4475-b4f3-c2377ae37545' [2023-06-26 13:09:52,898] INFO: Successfully triggered execution for data push job with id '2a26e6b1-9c0a-4475-b4f3-c2377ae37545' [2023-06-26 13:09:52,899] INFO: Wait for execution of data push job with id '2a26e6b1-9c0a-4475-b4f3-c2377ae37545'
[2023-06-26 13:09:52,931] INFO: Successfully created table 'EKKO' in data pool [2023-06-26 13:09:52,937] INFO: Successfully deleted data push job with id '2a26e6b1-9c0a-4475-b4f3-c2377ae37545'
[2023-06-26 13:09:52,951] WARNING: STRING columns are by default stored as VARCHAR(80) and therefore cut after 80 characters. You can specify a custom field length for each column using the `column_config` parameter.
[2023-06-26 13:09:52,960] INFO: Successfully created data push job with id 'e3338b4f-f83d-48d1-a6c5-edab338d946b' [2023-06-26 13:09:52,961] INFO: Add data frame as file chunks to data push job with id 'e3338b4f-f83d-48d1-a6c5-edab338d946b'
[2023-06-26 13:09:52,985] INFO: Successfully upserted file chunk to data push job with id 'e3338b4f-f83d-48d1-a6c5-edab338d946b' [2023-06-26 13:09:53,002] INFO: Successfully triggered execution for data push job with id 'e3338b4f-f83d-48d1-a6c5-edab338d946b' [2023-06-26 13:09:53,003] INFO: Wait for execution of data push job with id 'e3338b4f-f83d-48d1-a6c5-edab338d946b'
[2023-06-26 13:09:53,042] INFO: Successfully created table 'LFA1' in data pool [2023-06-26 13:09:53,050] INFO: Successfully deleted data push job with id 'e3338b4f-f83d-48d1-a6c5-edab338d946b'
DataPoolTable(name='LFA1', data_source_id=None, columns=[], schema_name='6c178afe-21e2-4f77-b862-e37653ae0b2e', data_pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e')
We can verify that the newly-created tables exist in our data pool by calling the get_tables()
method:
data_pool.get_tables()
[ DataPoolTable(name='ACTIVITIES', data_source_id=None, columns=[], schema_name='6c178afe-21e2-4f77-b862-e37653ae0b2e', data_pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e'), DataPoolTable(name='EKKO', data_source_id=None, columns=[], schema_name='6c178afe-21e2-4f77-b862-e37653ae0b2e', data_pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e'), DataPoolTable(name='EKPO', data_source_id=None, columns=[], schema_name='6c178afe-21e2-4f77-b862-e37653ae0b2e', data_pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e'), DataPoolTable(name='LFA1', data_source_id=None, columns=[], schema_name='6c178afe-21e2-4f77-b862-e37653ae0b2e', data_pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e') ]
3.2 Append data to existing table in the EMS¶
We can also choose to append our data to an already existing table in our data pool with the append()
method. The method takes as input arguments:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame |
A pandas dataframe containing the data | Required |
Important:
The column types and names of our dataframe must be the same as in the target table in the data pool, otherwise the append operation will fail.
Let's create a new activity table ACTIVITIES_APPEND
in our data pool, to which we want to append a new dataframe:
data_pool_table = data_pool.create_table(df=activity_df, table_name="ACTIVITIES_APPEND", drop_if_exists=False)
[2023-06-26 13:09:53,096] WARNING: STRING columns are by default stored as VARCHAR(80) and therefore cut after 80 characters. You can specify a custom field length for each column using the `column_config` parameter.
[2023-06-26 13:09:53,107] INFO: Successfully created data push job with id '3aac713c-fd8a-4c54-9cf7-c7bff347a108' [2023-06-26 13:09:53,108] INFO: Add data frame as file chunks to data push job with id '3aac713c-fd8a-4c54-9cf7-c7bff347a108'
[2023-06-26 13:09:53,133] INFO: Successfully upserted file chunk to data push job with id '3aac713c-fd8a-4c54-9cf7-c7bff347a108' [2023-06-26 13:09:53,154] INFO: Successfully triggered execution for data push job with id '3aac713c-fd8a-4c54-9cf7-c7bff347a108' [2023-06-26 13:09:53,155] INFO: Wait for execution of data push job with id '3aac713c-fd8a-4c54-9cf7-c7bff347a108'
[2023-06-26 13:09:53,195] INFO: Successfully created table 'ACTIVITIES_APPEND' in data pool [2023-06-26 13:09:53,205] INFO: Successfully deleted data push job with id '3aac713c-fd8a-4c54-9cf7-c7bff347a108'
We can now append another dataframe to the already existing table by calling the append()
method:
data_pool_table.append(activity_df)
[2023-06-26 13:09:53,241] INFO: Successfully created data push job with id '9f5d3b2c-f614-451b-b32e-23a6933580d7' [2023-06-26 13:09:53,243] INFO: Add data frame as file chunks to data push job with id '9f5d3b2c-f614-451b-b32e-23a6933580d7'
[2023-06-26 13:09:53,269] INFO: Successfully upserted file chunk to data push job with id '9f5d3b2c-f614-451b-b32e-23a6933580d7' [2023-06-26 13:09:53,293] INFO: Successfully triggered execution for data push job with id '9f5d3b2c-f614-451b-b32e-23a6933580d7' [2023-06-26 13:09:53,294] INFO: Wait for execution of data push job with id '9f5d3b2c-f614-451b-b32e-23a6933580d7'
[2023-06-26 13:09:53,352] INFO: Successfully deleted data push job with id '9f5d3b2c-f614-451b-b32e-23a6933580d7' [2023-06-26 13:09:53,352] INFO: Successfully appended rows to table 'ACTIVITIES_APPEND' in data pool
3.3 Upsert data to existing table in the EMS¶
Lastly, we can choose to upsert our data into an already existing data pool table with the upsert()
method. Upsert works similar to the append operation (i.e. it adds rows from a dataframe into a table) but replaces rows if they already exist. For this, we have to specify in keys
a list of column names according to which to check for equality. If two rows have the same values in all columns specified in keys
, they are marked as duplicates and replaced.
The upsert()
method takes the following input arguments:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame |
A pandas dataframe containing the data | Required |
keys |
List[str] |
List of column names according to which to check for equality | Required |
Let's create a new activity table ACTIVITIES_UPSERT
in our data pool, to which we want to upsert a new dataframe:
data_pool_table = data_pool.create_table(df=activity_df, table_name="ACTIVITIES_UPSERT", drop_if_exists=False)
[2023-06-26 13:09:53,376] WARNING: STRING columns are by default stored as VARCHAR(80) and therefore cut after 80 characters. You can specify a custom field length for each column using the `column_config` parameter.
[2023-06-26 13:09:53,388] INFO: Successfully created data push job with id 'd8498831-5942-45bc-a4d2-f3906baeb139' [2023-06-26 13:09:53,389] INFO: Add data frame as file chunks to data push job with id 'd8498831-5942-45bc-a4d2-f3906baeb139'
[2023-06-26 13:09:53,415] INFO: Successfully upserted file chunk to data push job with id 'd8498831-5942-45bc-a4d2-f3906baeb139' [2023-06-26 13:09:53,440] INFO: Successfully triggered execution for data push job with id 'd8498831-5942-45bc-a4d2-f3906baeb139' [2023-06-26 13:09:53,441] INFO: Wait for execution of data push job with id 'd8498831-5942-45bc-a4d2-f3906baeb139'
[2023-06-26 13:09:53,496] INFO: Successfully created table 'ACTIVITIES_UPSERT' in data pool [2023-06-26 13:09:53,508] INFO: Successfully deleted data push job with id 'd8498831-5942-45bc-a4d2-f3906baeb139'
We can now upsert another dataframe by calling the upsert()
method. Here, we specify _CASE_KEY
and ACTIVITY_EN
as the columns according to which to check for equality:
data_pool_table.upsert(activity_df, keys=["_CASE_KEY", "ACTIVITY_EN"])
[2023-06-26 13:09:53,539] INFO: Successfully created data push job with id '541edf0d-8784-460b-92f4-2438d3dfb445' [2023-06-26 13:09:53,540] INFO: Add data frame as file chunks to data push job with id '541edf0d-8784-460b-92f4-2438d3dfb445'
[2023-06-26 13:09:53,568] INFO: Successfully upserted file chunk to data push job with id '541edf0d-8784-460b-92f4-2438d3dfb445' [2023-06-26 13:09:53,595] INFO: Successfully triggered execution for data push job with id '541edf0d-8784-460b-92f4-2438d3dfb445' [2023-06-26 13:09:53,596] INFO: Wait for execution of data push job with id '541edf0d-8784-460b-92f4-2438d3dfb445'
[2023-06-26 13:09:53,658] INFO: Successfully deleted data push job with id '541edf0d-8784-460b-92f4-2438d3dfb445' [2023-06-26 13:09:53,659] INFO: Successfully upserted rows to table 'ACTIVITIES_UPSERT' in data pool
4. Add table to a data model¶
After having uploaded our data into the data pool (either as a new table or by appending/upserting into an existing one), we can add the table into a data model.
For this, we navigate to the data model, which we created in the Data Integration - Introduction tutorial:
data_model = data_pool.get_data_models().find("PyCelonis Tutorial Data Model")
data_model
DataModel(id='0caea823-104c-4555-9b58-678a727c62b2', name='PyCelonis Tutorial Data Model', pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e')
To add a table from the data pool into the data model, we have to call the add_table()
method. The method takes as input arguments:
Name | Type | Description | Default |
---|---|---|---|
name |
str |
Name of the table inside our data pool | Required |
alias |
str |
Alias for the table, i.e. how the name should be displayed inside our data model | None |
data_model.add_table(name="ACTIVITIES", alias="ACTIVITIES")
data_model.add_table(name="EKPO", alias="EKPO")
data_model.add_table(name="EKKO", alias="EKKO")
data_model.add_table(name="LFA1", alias="LFA1")
[2023-06-26 13:09:53,708] INFO: Successfully added data model table with id '9379c106-9e44-4e7a-b9a3-2edd24f2a9cb' to data model [2023-06-26 13:09:53,722] INFO: Successfully added data model table with id '4ce53164-90cb-4743-b828-58440e69c606' to data model [2023-06-26 13:09:53,738] INFO: Successfully added data model table with id '76eb78e3-3cdc-4100-b741-39bfcb0cae4e' to data model [2023-06-26 13:09:53,754] INFO: Successfully added data model table with id '141c3b90-17f0-4581-8182-f3f8842f1154' to data model
DataModelTable(id='141c3b90-17f0-4581-8182-f3f8842f1154', data_model_id='0caea823-104c-4555-9b58-678a727c62b2', name='LFA1', alias='LFA1', data_pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e')
The method will take the table from our data pool and create a reference to it inside our data model, including all properties, such as column names and data types. To verify that the tables exist in our data model, we can call the get_tables()
method:
data_model.get_tables()
[ DataModelTable(id='9379c106-9e44-4e7a-b9a3-2edd24f2a9cb', data_model_id='0caea823-104c-4555-9b58-678a727c62b2', name='ACTIVITIES', alias='ACTIVITIES', data_pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e'), DataModelTable(id='4ce53164-90cb-4743-b828-58440e69c606', data_model_id='0caea823-104c-4555-9b58-678a727c62b2', name='EKPO', alias='EKPO', data_pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e'), DataModelTable(id='76eb78e3-3cdc-4100-b741-39bfcb0cae4e', data_model_id='0caea823-104c-4555-9b58-678a727c62b2', name='EKKO', alias='EKKO', data_pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e'), DataModelTable(id='141c3b90-17f0-4581-8182-f3f8842f1154', data_model_id='0caea823-104c-4555-9b58-678a727c62b2', name='LFA1', alias='LFA1', data_pool_id='6c178afe-21e2-4f77-b862-e37653ae0b2e') ]
5. Reload data model¶
Note that the add_table()
method only creates a reference of the data pool table inside our data model but does not reload the data model. For that, we have to call the reload()
method:
data_model.reload()
[2023-06-26 13:09:53,824] INFO: Successfully triggered data model reload for data model with id '0caea823-104c-4555-9b58-678a727c62b2' [2023-06-26 13:09:53,825] INFO: Wait for execution of data model reload for data model with id '0caea823-104c-4555-9b58-678a727c62b2'
This method will load the data for all tables inside our data model. However, if we only want to load the data for selected tables, we can also perform a partial_reload()
and specify inside data_model_table_ids
the table IDs, for which we want to load the data:
tables = data_model.get_tables()
ekko = tables.find("EKKO")
ekpo = tables.find("EKPO")
data_model.partial_reload(data_model_table_ids=[ekko.id, ekpo.id])
[2023-06-26 13:09:53,945] INFO: Successfully triggered data model reload for data model with id '0caea823-104c-4555-9b58-678a727c62b2' [2023-06-26 13:09:53,946] INFO: Wait for execution of data model reload for data model with id '0caea823-104c-4555-9b58-678a727c62b2'
Conclusion¶
Congratulations! You have learned how to upload data from your local Python project as tables inside your data pool, how to add those tables into a data model, and how to reload a data model in order to populate the model tables with data from the pool tables. In the next tutorial Data Export, you will learn how to export data from the Celonis EMS into your local Python project.