notebook.ipynb 5.8 KB

from pathlib import PurePath

filename = PurePath("Excel\\Mappe1.xlsx")

print(filename.absolute)
print(filename.name)
# prints "raw_data.txt"

print(filename.suffix)
# prints "txt"

print(filename.stem)
# prints "raw_data"

<bound method Path.absolute of WindowsPath('Excel/Mappe1.xlsx')>
Mappe1.xlsx
.xlsx
Mappe1
import win32com.client
tr = win32com.client.gencache.EnsureDispatch("CognosTransformer.Application")
---------------------------------------------------------------------------
com_error                                 Traceback (most recent call last)
C:\dev\Python\Python38-32\lib\site-packages\win32com\client\gencache.py in EnsureDispatch(prog_id, bForDemand)
    529                 try:
--> 530                         ti = disp._oleobj_.GetTypeInfo()
    531                         disp_clsid = ti.GetTypeAttr()[0]

com_error: (-2147467263, 'Nicht implementiert', None, None)

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-4-45d6d54b965f> in <module>
      1 import win32com.client
----> 2 tr = win32com.client.gencache.EnsureDispatch("CognosTransformer.Application")

C:\dev\Python\Python38-32\lib\site-packages\win32com\client\gencache.py in EnsureDispatch(prog_id, bForDemand)
    539                         disp = disp_class(disp._oleobj_)
    540                 except pythoncom.com_error:
--> 541                         raise TypeError("This COM object can not automate the makepy process - please run makepy manually for this object")
    542         return disp
    543 

TypeError: This COM object can not automate the makepy process - please run makepy manually for this object
import sys
from win32com.client import makepy

outputFile = "C:\\Projekte\\Python\\transformer_automation.py"
comTypeLibraryOrDLL = "C:\\Program Files (x86)\\Cognos\\cer5\\bin\\transdll.dll"
sys.argv = ["makepy", "-o", outputFile, comTypeLibraryOrDLL]

makepy.main ()
Could not locate a type library matching 'C:\Program Files (x86)\Cognos\cer5\bin\trnsfrmr.dll'