Skip to main content

Python Scripting Questions

Description

Area to discuss python scripting questions.

Renaming a db in Python

I have been working for quite some time on renaming a database.

I am getting an error that is not very descriptive. Here is a snippet of the code. Any ideas would be appreciated

messagebox.showinfo("From", rootfolder + first_db)
messagebox.showinfo("To", rootfolder +prefix + "IMD")
Client.RenameDatabase (first_db, prefix + ".IMD")

Thanks,

Randy

Get installed IDEA version with python code

Hi Brian,
Hi at all,

I have specific python code that I put into a python.py file and run it from within IDEA. Now, I would like detect in my python code the installed IDEA version, to be able to do something like

if IDEA_version >= 12:

else:

So how can I get the installed IDEA version from Python code?

Thanks for any help!

Read IMD File from Python

Hi all,
I tried to access one my IMD files directly from Python using this code:
 
import pyodbc
 
import pandas as pd
 
# Define your connection string (this is a generic example and would need to be adjusted)
 
conn_str = (
 
    "DRIVER={CaseWare IDEA Driver};"
 
    "DSN=NSSO2018;"
 
    "DBQ=D:/2018 database;"
 
)
 

How do I send 2 columns as arrays to Python

Gereetings,I am trying to send two arrays from IDEAScript to Python. I know how to do it with 1 array:
In ISS: Client.RunPythonEx "Macros.ILB\PythonTest.py", array1
In Python: arguments = sys.argv[1] but I don't know how to do it with 2 arrays. How can I send 2 arrays to 1 script?
Any assistance or guidance in resolving this issue would be greatly appreciated.
Thank you.

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")

 

Execute Python with IDEAScript

Hello friends,
 
I'm having trouble running a .py file with IDEA, I need to import 25 million XML files into IDEA, we created a macro that automatically imports the files for us, but it takes a long time to join the databases in IDEA and organize them, we came up with doing a PYTHON file that allows us to do this faster and in a single document, to import into IDEA later.
the file is the following:

Rename a column from within Python, error "Property 'NewField.Type' can not be set."

Suppose I have a simple task, I want to rename a column. My IDEAScript is as follows:
 
Sub Main
    Call ModifyField()
End Sub
 
Function ModifyField
    Set db = Client.OpenDatabase("myfile.IMD")
    Set task = db.TableManagement
    Set field = db.TableDef.NewField
    field.Name = "newname"
    field.Description = "field"
    field.Type = WI_CHAR_FIELD
    field.Equation = ""

Error when trying to perform IDEAScript extraction in Python

I have an IDEA file from which I want to perform a simple extraction (column1 equals 6) and save this as a new file. My IDEAScript is as follows (see also attached file):
 
Sub Main
         Call DirectExtraction()   
End Sub
 
Function DirectExtraction
         Set db = Client.OpenDatabase("myfile.IMD")
         Set task = db.Extraction