Skip to main content

Python Scripting Questions

Description

Area to discuss python scripting questions.

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

Using win32ComClient along with ImportDelimFile in Python to import csv

My problem is related to this one:
http://www.ideascripting.com/forum/python-import-txt-file
However, slightly different, as I can say for sure that my rdf import definition file is correct.
 
The task is actually quite simple: I have a csv file, a rdf file and I want to import the csv file into idea. When I do it manually, it works. Now, I need to do it with python code. My code so far is:
 
import win32com.client as win32ComClient
 

IDEALib for Python

HI. I'm recently working with IDEA and Python.I read in the documentation that it is possible to use the IDEALib library.My question is how do I install the library in Pycharm or VSCode?
Do I need to copy from the site package into my Python path?
I have a problem.When I run my script it says No module named 'win32api'
Regards

Python: Import TXT File

Hello, I would like to import a SAP table (txt file) into IDEA using Python.

When running the code I get the following error message:
IDEA.ImportDelimFile(importPath, dbName, False," ", rdfPath, True)
File "<COMObject Idea.IdeaClient>", line 3, in ImportDelimFile
pywintypes.com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, 'Idea.IdeaClient.1', 'Invalid record definition file', None, 0, -2147467259), None)
 
Can anyone help me?