Idea database to a pandas DF using win32com.client

4 posts / 0 new
Last post
bluered83132
Offline
Joined: 09/07/2023 - 04:53
Idea database to a pandas DF using win32com.client

Hello everyone! I'm looking to export my database into a pandas dataframe.
When utilizing an internal compiler, the process looks like this:
df = Idea.idea2py(database='mydatabase.idm', client=client)
 
However, I'd like to use the original Python for its additional debugging features.

import win32com.client as win32client
idea = win32client.Dispatch(dispatch="Idea.IdeaClient")
db = idea.opendatabase("mydatabase.idm")

 
What Python code should I use to accomplish this using the IdeaClient library?

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi bluered83132,

What the IDEALib.py is doing when it is calling the idea2py function is that it is first saving the file as a text file.  Here is the function from IDEALib.py that performs this task:


def _export_database_from_IDEA(db,client,tempPath):    
    exportPath = path.join(tempPath,"tempExport.del")     
    task = db.ExportDatabase()    
    task.IncludeAllFields()
    task.IncludeFieldNames ="TRUE"
    eqn = ""
    task.Separators(DELIMITER,DECIMAL_SEPARATOR)

    task.PerformTask(exportPath,"Database","DEL UTF-8",1,db.Count,eqn)

    return exportPath 

You would then import the file using pandas.

Hope that helps out a bit.

bluered83132
Offline
Joined: 09/07/2023 - 04:53

Thank you so much for your help! As i understood, there is no way to directly parse database through win32client, and idea2py after export also reads some temp file. Am i right?

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

That is right, there is no way to do this directly.  You have to export the IDEA database into a text file and then bring this into Pandas, do your analysis and then send it back to IDEA.  IDEA and pandas do not talk directly to each other.