notebook.ipynb 20 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'
sentence = 'g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyrq ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.'
url = 'http://www.pythonchallenge.com/pc/def/map.html'
alphabet = [chr(x) for x in range(97, 123)] + ['a', 'b']
''.join([alphabet[alphabet.index(x)+2] if x in alphabet else x for x in url])
'jvvr://yyy.ravjqpejcnngpig.eqo/re/fgh/ocr.jvon'
help(str.maketrans)
Help on built-in function maketrans:

maketrans(...)
    Return a translation table usable for str.translate().
    
    If there is only one argument, it must be a dictionary mapping Unicode
    ordinals (integers) or characters to Unicode ordinals, strings or None.
    Character keys will be then converted to ordinals.
    If there are two arguments, they must be strings of equal length, and
    in the resulting dictionary, each character in x will be mapped to the
    character at the same position in y. If there is a third argument, it
    must be a string, whose characters will be mapped to None in the result.

import requests
import re

res = requests.get('http://www.pythonchallenge.com/pc/def/ocr.html')
''.join([x if x in alphabet else '' for x in res.content.decode('utf-8')])
# p.match(res.content.decode())
'htmlheadtitleocrtitlelinkrelstylesheettypetextcsshrefstylecssheadbodycenterimgsrcocrjpgbrfontcolorcrecognizethecharactersmaybetheyareinthebookbrbuttheyareinthepagesourcecenterbrbrbrfontsizecolorgoldeneraltipslisethehintsheyarehelpfulmostofthetimeslilinvestigatethedatagiventoyoulilivoidlookingforspoilerslibrorumsahrefhttpwwwpythonchallengecomforumsythonhallengeorumsareadbeforeyoupostbrircfreenodenetpythonchallengebrbroseethesolutionstothepreviouslevelreplacepcwithpcciegotohttpwwwpythonchallengecompccdefocrhtmlbodyhtmlfindrarecharactersinthemessbelowequality'
import requests
import re

res = requests.get('http://www.pythonchallenge.com/pc/def/equality.html')
p = re.compile(r'[^A-Z][A-Z]{3}[a-z][A-Z]{3}[^A-Z]')
m = p.findall(res.content.decode('utf-8'))
print(m)
['qIQNlQSLi', 'eOEKiVEYj', 'aZADnMCZq', 'bZUTkLYNg', 'uCNDeHSBj', 'kOIXdKBFh', 'dXJVlGZVm', 'gZAGiLQZx', 'vCJAsACFl', 'qKWGtIDCj']
import gcstruct
gcstruct.struct_config('P:\\SKR51_GCStruct\\GCStruct_Portal')
df = gcstruct.accounts_from_csv(gcstruct.config['struct'])
df
Konto_Nr Konto_Bezeichnung Konto_Art Konto_KST Konto_STK Konto_1 Konto_2 Konto_3 Konto_4 Konto_5 ... LetzteEbene4_Nr LetzteEbene4_Bez Teile LetzteEbene5 LetzteEbene5_Nr LetzteEbene5_Bez Weitere LetzteEbene6 LetzteEbene6_Nr LetzteEbene6_Bez
0 0001 Aufwendungen für die Ingangsetzung und Erweite... 1 ... XX;;;;;;;;; XX XX;;;;;;;;; XX
1 0010 Entgeltlich erworbene Konzessionen, gewerblich... 1 ... XX;;;;;;;;; XX XX;;;;;;;;; XX
2 0015 Konzessionen 1 ... XX;;;;;;;;; XX XX;;;;;;;;; XX
3 0020 Gewerbliche Schutzrechte 1 ... XX;;;;;;;;; XX XX;;;;;;;;; XX
4 0025 Ähnliche Rechte und Werte 1 ... XX;;;;;;;;; XX XX;;;;;;;;; XX
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
5504 MAR_0600 Volkswagen PKW MAR ... ;;;;;;;;; ;;;;;;;;;
5505 MAR_9101 Volvo MAR ... ;;;;;;;;; ;;;;;;;;;
5506 MAR_0100 Daimler MAR ... ;;;;;;;;; ;;;;;;;;;
5507 MAR_0110 Mercedes Benz MAR ... ;;;;;;;;; ;;;;;;;;;
5508 MAR_0121 smart Pkw MAR ... ;;;;;;;;; ;;;;;;;;;

5509 rows × 94 columns