# Nutzung einer IDEA-Datei in Python mittels IDEALib.py - hier ein Beipielsskript

#!/usr/bin/env python # coding: utf-8 # # IDEA to Python # # The easiest way to transfter an IDEA imd file to python for analysis is to use the IDEALib.py module the comes installed with IDEA. This module contains the code to easily transfer the file from IDEA to Python and back again. # # If the script is being run directly from IDEA you will have access to it but if you are doing your development outside of IDEA you will have to copy the file into your python working folder in able to access it. The file can be found here: # # C:\Program Files\CaseWare IDEA\IDEA\Lib\site-packages # # Once copied over you should be able to access it using import. # # In order to transfer a file from IDEA to python you will need to import IDEALib and pandas as the IDEALib transfer the IDEA file to a pandas dataframe. import IDEALib as ideaLib import pandas as pd # You will then need to call the IDEA client. What this is doing is access IDEA from python in order to read the idea file. idea = ideaLib.idea_client() # In order to read the file IDEA must be open to the project folder in which the file is stored. The syntax is to call the idea2py function from the ideaLib module, it needs two parameters, the name of the file to copy over and the client, which we created in the previous line. Depending on the size of the file it will take a few seconds or more to transfer to the Python dataframe. Below we are transfering it to the variable df. df = ideaLib.idea2py("Sample-Detailed Sales.IDM", idea) # Next we will extract all transactions for the first quarter from the dataframe. df_1st_Quarter = None start_date = '01-01-2020' end_date = '03-31-2020' criteria = (df['INV_DATE'] >= start_date) & (df['INV_DATE'] <= end_date) df_1st_Quarter = df[criteria] df_1st_Quarter # Next we will send this information back to IDEA. Again the IDEAlib has a function to do this called py2idea which needs the dataframe to transfer and the name of the file to be created in IDEA. ideaLib.py2idea(df_1st_Quarter, 'First Quarter Invoices')