WHY NOT PYTHON ? TM1 through python
TM1py
In order to understand TM1py, lets understand what is py?
Py stands for Python. Python is an interpreted, object-oriented, general-purpose programming language with dynamic semantics. Its built-in data structures, combined with dynamic typing and dynamic binding, make it very attractive for rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the
extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.
Why use Python?
Python’s expansive library of open source data analysis tools, web frameworks, and testing
instruments make its ecosystem one of the largest out of any programming community. Python is an
accessible language for new programmers because the community provides many introductory
resources.
What is TM1py?
TM1py is a Python package that connects with TM1 REST API which make it simple to use library and build stuff with TM1 and Python.
With TM1py there are new possibilities to enhance your TM1 application, such as:
- Express complex calculations for TM1 with python
- Bring Data Science into the picture
- Go beyond TI
- Access TM1 data from other applications, such as PowerBI
- Control all TM1 objects from Python
- Load TM1 data into pandas for statistical analysis
- Load FX, Stock and GDP data from external sources into your cubes
- Synchronize cubes from different TM1 instances
- Clean your TM1 models through regular expressions
- Generate MDX Queries from existing cube views
- Analyse Processing Feeders time
- Maintain dimensions and subsets with python
And so on…
Connecting TM1 with Python
1. Install Python
- Select PIP (Package management system to install various packages)
- Add Python path to Environmental Variables.
2. Enable TM1 REST API
- Edit the tm1s.cfg file of the TM1 servers that you want to enable.
- Add the entry HTTPPortNumber=####
- Restart the TM1 servers.
3. Open cmd and type pip install TM1py
4. After install TM1py we need to import TM1py Services
- Type> Python
- Type> from TM1py.Services import TM1Service
5. After exporting TM1 services we need to create a connection with TM1 server.
- Type> tm1=TM1Service (address=’localhost’, port=12354, user=’admin’, password=’apple’, ssl=True) {here tm1 is a variable created}
- Type> print (tm1) {to check if connection has established}
Importing TM1 cube Data using Python
Below is the script to import TM1 data to csv format using Python and Pandas package. When working with tabular data, such as data stored in spreadsheets or database, pandas is the right tool. pandas will help to explore, clean and process data. In pandas, a data table is called a DataFrame.
Getting data using MDX
Note: Here I’m using juypter notebook to write and execute my script this can be written in python
native tool called IDLE or in CMD as well.
Cube Name
Executing above created MDX query
Note: Here I’m using juypter notebook to write and execute my script this can be written in python native tool called IDLE or in CMD as well.