{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "<bound method Path.absolute of WindowsPath('Excel/Mappe1.xlsx')>\nMappe1.xlsx\n.xlsx\nMappe1\n"
    }
   ],
   "source": [
    "from pathlib import PurePath\n",
    "\n",
    "filename = PurePath(\"Excel\\\\Mappe1.xlsx\")\n",
    "\n",
    "print(filename.absolute)\n",
    "print(filename.name)\n",
    "# prints \"raw_data.txt\"\n",
    "\n",
    "print(filename.suffix)\n",
    "# prints \"txt\"\n",
    "\n",
    "print(filename.stem)\n",
    "# prints \"raw_data\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "error",
     "ename": "TypeError",
     "evalue": "This COM object can not automate the makepy process - please run makepy manually for this object",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mcom_error\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32mC:\\dev\\Python\\Python38-32\\lib\\site-packages\\win32com\\client\\gencache.py\u001b[0m in \u001b[0;36mEnsureDispatch\u001b[1;34m(prog_id, bForDemand)\u001b[0m\n\u001b[0;32m    529\u001b[0m                 \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 530\u001b[1;33m                         \u001b[0mti\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdisp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_oleobj_\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mGetTypeInfo\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    531\u001b[0m                         \u001b[0mdisp_clsid\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mti\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mGetTypeAttr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mcom_error\u001b[0m: (-2147467263, 'Nicht implementiert', None, None)",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-4-45d6d54b965f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mwin32com\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mtr\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mwin32com\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgencache\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mEnsureDispatch\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"CognosTransformer.Application\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mC:\\dev\\Python\\Python38-32\\lib\\site-packages\\win32com\\client\\gencache.py\u001b[0m in \u001b[0;36mEnsureDispatch\u001b[1;34m(prog_id, bForDemand)\u001b[0m\n\u001b[0;32m    539\u001b[0m                         \u001b[0mdisp\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdisp_class\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdisp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_oleobj_\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    540\u001b[0m                 \u001b[1;32mexcept\u001b[0m \u001b[0mpythoncom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcom_error\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 541\u001b[1;33m                         \u001b[1;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"This COM object can not automate the makepy process - please run makepy manually for this object\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    542\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mdisp\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    543\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mTypeError\u001b[0m: This COM object can not automate the makepy process - please run makepy manually for this object"
     ]
    }
   ],
   "source": [
    "import win32com.client\n",
    "tr = win32com.client.gencache.EnsureDispatch(\"CognosTransformer.Application\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "Could not locate a type library matching 'C:\\Program Files (x86)\\Cognos\\cer5\\bin\\trnsfrmr.dll'\n"
    }
   ],
   "source": [
    "import sys\n",
    "from win32com.client import makepy\n",
    "\n",
    "outputFile = \"C:\\\\Projekte\\\\Python\\\\transformer_automation.py\"\n",
    "comTypeLibraryOrDLL = \"C:\\\\Program Files (x86)\\\\Cognos\\\\cer5\\\\bin\\\\transdll.dll\"\n",
    "sys.argv = [\"makepy\", \"-o\", outputFile, comTypeLibraryOrDLL]\n",
    "\n",
    "makepy.main ()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "'jvvr://yyy.ravjqpejcnngpig.eqo/re/fgh/ocr.jvon'"
      ]
     },
     "metadata": {},
     "execution_count": 18
    }
   ],
   "source": [
    "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.'\n",
    "url = 'http://www.pythonchallenge.com/pc/def/map.html'\n",
    "alphabet = [chr(x) for x in range(97, 123)] + ['a', 'b']\n",
    "''.join([alphabet[alphabet.index(x)+2] if x in alphabet else x for x in url])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Help on built-in function maketrans:\n\nmaketrans(...)\n    Return a translation table usable for str.translate().\n    \n    If there is only one argument, it must be a dictionary mapping Unicode\n    ordinals (integers) or characters to Unicode ordinals, strings or None.\n    Character keys will be then converted to ordinals.\n    If there are two arguments, they must be strings of equal length, and\n    in the resulting dictionary, each character in x will be mapped to the\n    character at the same position in y. If there is a third argument, it\n    must be a string, whose characters will be mapped to None in the result.\n\n"
     ]
    }
   ],
   "source": [
    "help(str.maketrans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "'htmlheadtitleocrtitlelinkrelstylesheettypetextcsshrefstylecssheadbodycenterimgsrcocrjpgbrfontcolorcrecognizethecharactersmaybetheyareinthebookbrbuttheyareinthepagesourcecenterbrbrbrfontsizecolorgoldeneraltipslisethehintsheyarehelpfulmostofthetimeslilinvestigatethedatagiventoyoulilivoidlookingforspoilerslibrorumsahrefhttpwwwpythonchallengecomforumsythonhallengeorumsareadbeforeyoupostbrircfreenodenetpythonchallengebrbroseethesolutionstothepreviouslevelreplacepcwithpcciegotohttpwwwpythonchallengecompccdefocrhtmlbodyhtmlfindrarecharactersinthemessbelowequality'"
      ]
     },
     "metadata": {},
     "execution_count": 31
    }
   ],
   "source": [
    "import requests\n",
    "import re\n",
    "\n",
    "res = requests.get('http://www.pythonchallenge.com/pc/def/ocr.html')\n",
    "''.join([x if x in alphabet else '' for x in res.content.decode('utf-8')])\n",
    "# p.match(res.content.decode())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "['qIQNlQSLi', 'eOEKiVEYj', 'aZADnMCZq', 'bZUTkLYNg', 'uCNDeHSBj', 'kOIXdKBFh', 'dXJVlGZVm', 'gZAGiLQZx', 'vCJAsACFl', 'qKWGtIDCj']\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "import re\n",
    "\n",
    "res = requests.get('http://www.pythonchallenge.com/pc/def/equality.html')\n",
    "p = re.compile(r'[^A-Z][A-Z]{3}[a-z][A-Z]{3}[^A-Z]')\n",
    "m = p.findall(res.content.decode('utf-8'))\n",
    "print(m)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "      Konto_Nr                                  Konto_Bezeichnung Konto_Art  \\\n",
       "0         0001  Aufwendungen für die Ingangsetzung und Erweite...         1   \n",
       "1         0010  Entgeltlich erworbene Konzessionen, gewerblich...         1   \n",
       "2         0015                                       Konzessionen         1   \n",
       "3         0020                           Gewerbliche Schutzrechte         1   \n",
       "4         0025                          Ähnliche Rechte und Werte         1   \n",
       "...        ...                                                ...       ...   \n",
       "5504  MAR_0600                                     Volkswagen PKW       MAR   \n",
       "5505  MAR_9101                                              Volvo       MAR   \n",
       "5506  MAR_0100                                            Daimler       MAR   \n",
       "5507  MAR_0110                                      Mercedes Benz       MAR   \n",
       "5508  MAR_0121                                          smart Pkw       MAR   \n",
       "\n",
       "     Konto_KST Konto_STK Konto_1 Konto_2 Konto_3 Konto_4 Konto_5  ...  \\\n",
       "0                                                                 ...   \n",
       "1                                                                 ...   \n",
       "2                                                                 ...   \n",
       "3                                                                 ...   \n",
       "4                                                                 ...   \n",
       "...        ...       ...     ...     ...     ...     ...     ...  ...   \n",
       "5504                                                              ...   \n",
       "5505                                                              ...   \n",
       "5506                                                              ...   \n",
       "5507                                                              ...   \n",
       "5508                                                              ...   \n",
       "\n",
       "     LetzteEbene4_Nr LetzteEbene4_Bez        Teile LetzteEbene5  \\\n",
       "0                                      XX;;;;;;;;;           XX   \n",
       "1                                      XX;;;;;;;;;           XX   \n",
       "2                                      XX;;;;;;;;;           XX   \n",
       "3                                      XX;;;;;;;;;           XX   \n",
       "4                                      XX;;;;;;;;;           XX   \n",
       "...              ...              ...          ...          ...   \n",
       "5504                                     ;;;;;;;;;                \n",
       "5505                                     ;;;;;;;;;                \n",
       "5506                                     ;;;;;;;;;                \n",
       "5507                                     ;;;;;;;;;                \n",
       "5508                                     ;;;;;;;;;                \n",
       "\n",
       "     LetzteEbene5_Nr LetzteEbene5_Bez      Weitere LetzteEbene6  \\\n",
       "0                                      XX;;;;;;;;;           XX   \n",
       "1                                      XX;;;;;;;;;           XX   \n",
       "2                                      XX;;;;;;;;;           XX   \n",
       "3                                      XX;;;;;;;;;           XX   \n",
       "4                                      XX;;;;;;;;;           XX   \n",
       "...              ...              ...          ...          ...   \n",
       "5504                                     ;;;;;;;;;                \n",
       "5505                                     ;;;;;;;;;                \n",
       "5506                                     ;;;;;;;;;                \n",
       "5507                                     ;;;;;;;;;                \n",
       "5508                                     ;;;;;;;;;                \n",
       "\n",
       "     LetzteEbene6_Nr LetzteEbene6_Bez  \n",
       "0                                      \n",
       "1                                      \n",
       "2                                      \n",
       "3                                      \n",
       "4                                      \n",
       "...              ...              ...  \n",
       "5504                                   \n",
       "5505                                   \n",
       "5506                                   \n",
       "5507                                   \n",
       "5508                                   \n",
       "\n",
       "[5509 rows x 94 columns]"
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Konto_Nr</th>\n      <th>Konto_Bezeichnung</th>\n      <th>Konto_Art</th>\n      <th>Konto_KST</th>\n      <th>Konto_STK</th>\n      <th>Konto_1</th>\n      <th>Konto_2</th>\n      <th>Konto_3</th>\n      <th>Konto_4</th>\n      <th>Konto_5</th>\n      <th>...</th>\n      <th>LetzteEbene4_Nr</th>\n      <th>LetzteEbene4_Bez</th>\n      <th>Teile</th>\n      <th>LetzteEbene5</th>\n      <th>LetzteEbene5_Nr</th>\n      <th>LetzteEbene5_Bez</th>\n      <th>Weitere</th>\n      <th>LetzteEbene6</th>\n      <th>LetzteEbene6_Nr</th>\n      <th>LetzteEbene6_Bez</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>0001</td>\n      <td>Aufwendungen für die Ingangsetzung und Erweite...</td>\n      <td>1</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>...</td>\n      <td></td>\n      <td></td>\n      <td>XX;;;;;;;;;</td>\n      <td>XX</td>\n      <td></td>\n      <td></td>\n      <td>XX;;;;;;;;;</td>\n      <td>XX</td>\n      <td></td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>0010</td>\n      <td>Entgeltlich erworbene Konzessionen, gewerblich...</td>\n      <td>1</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>...</td>\n      <td></td>\n      <td></td>\n      <td>XX;;;;;;;;;</td>\n      <td>XX</td>\n      <td></td>\n      <td></td>\n      <td>XX;;;;;;;;;</td>\n      <td>XX</td>\n      <td></td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>0015</td>\n      <td>Konzessionen</td>\n      <td>1</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>...</td>\n      <td></td>\n      <td></td>\n      <td>XX;;;;;;;;;</td>\n      <td>XX</td>\n      <td></td>\n      <td></td>\n      <td>XX;;;;;;;;;</td>\n      <td>XX</td>\n      <td></td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>0020</td>\n      <td>Gewerbliche Schutzrechte</td>\n      <td>1</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>...</td>\n      <td></td>\n      <td></td>\n      <td>XX;;;;;;;;;</td>\n      <td>XX</td>\n      <td></td>\n      <td></td>\n      <td>XX;;;;;;;;;</td>\n      <td>XX</td>\n      <td></td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>0025</td>\n      <td>Ähnliche Rechte und Werte</td>\n      <td>1</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>...</td>\n      <td></td>\n      <td></td>\n      <td>XX;;;;;;;;;</td>\n      <td>XX</td>\n      <td></td>\n      <td></td>\n      <td>XX;;;;;;;;;</td>\n      <td>XX</td>\n      <td></td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>5504</th>\n      <td>MAR_0600</td>\n      <td>Volkswagen PKW</td>\n      <td>MAR</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>...</td>\n      <td></td>\n      <td></td>\n      <td>;;;;;;;;;</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>;;;;;;;;;</td>\n      <td></td>\n      <td></td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>5505</th>\n      <td>MAR_9101</td>\n      <td>Volvo</td>\n      <td>MAR</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>...</td>\n      <td></td>\n      <td></td>\n      <td>;;;;;;;;;</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>;;;;;;;;;</td>\n      <td></td>\n      <td></td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>5506</th>\n      <td>MAR_0100</td>\n      <td>Daimler</td>\n      <td>MAR</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>...</td>\n      <td></td>\n      <td></td>\n      <td>;;;;;;;;;</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>;;;;;;;;;</td>\n      <td></td>\n      <td></td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>5507</th>\n      <td>MAR_0110</td>\n      <td>Mercedes Benz</td>\n      <td>MAR</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>...</td>\n      <td></td>\n      <td></td>\n      <td>;;;;;;;;;</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>;;;;;;;;;</td>\n      <td></td>\n      <td></td>\n      <td></td>\n    </tr>\n    <tr>\n      <th>5508</th>\n      <td>MAR_0121</td>\n      <td>smart Pkw</td>\n      <td>MAR</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>...</td>\n      <td></td>\n      <td></td>\n      <td>;;;;;;;;;</td>\n      <td></td>\n      <td></td>\n      <td></td>\n      <td>;;;;;;;;;</td>\n      <td></td>\n      <td></td>\n      <td></td>\n    </tr>\n  </tbody>\n</table>\n<p>5509 rows × 94 columns</p>\n</div>"
     },
     "metadata": {},
     "execution_count": 4
    }
   ],
   "source": [
    "import gcstruct\n",
    "gcstruct.struct_config('P:\\\\SKR51_GCStruct\\\\GCStruct_Portal')\n",
    "df = gcstruct.accounts_from_csv(gcstruct.config['struct'])\n",
    "df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python38232bitbfe000d0e0804f0ba6fab56a16b38371",
   "display_name": "Python 3.8.2 32-bit",
   "language": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}