Hi All,
Earlier I had asked a question regarding how we can save/extract a table in our EMS as a csv file in our machine learning work bench, seeing the reactions or the lack of replies I got for the topic I think it would be helpful if I explain the code that I used/found to save the file as csv in my ML workbench.
from pycelonis import get_celonis
import pycelonis.pql as pql
from pycelonis.config import Config
celonis = get_celonis()
data_pool = celonis.data_integration.get_data_pools().find("Datapool name")
data_model = data_pool.get_data_models().find("Datamodel name")
Config.DEFAULT_DATA_MODEL = data_model
tables = data_model.get_tables()
table_name = data_model.get_tables().find("Table to find out")
table_columns = table_name.get_columns()
df = pql.DataFrame(
{
"column1": table_columns.find("column name in the table which has to be extracted "),
"column2": table_columns.find(" column name for column 2 "),
"column3": table_columns.find("column name for column 3"),
}
)
pandas_df = df.to_pandas()
pandas_df
df_to_csv_mode = True
filepath = "your filepath"
if df_to_csv_mode: pandas_df.to_csv(filepath + 'tablename.csv', encoding='utf-8', index=False)
(NB: I used pycelonis version 2.5.0 )