working on data validation

This commit is contained in:
Georg ´Brantegger
2022-09-14 15:13:44 +02:00
parent e9f7aa92a0
commit 137182ab10
8 changed files with 10901 additions and 14 deletions

View File

@@ -0,0 +1,102 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import time\n",
"from datetime import datetime\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"def unpack_line(str):\n",
" index_1 = str.find(';')\n",
" index_2 = str.find(';',index_1)\n",
" index_3 = str.find(';',index_2)\n",
" index_4 = str.find(';',index_3)\n",
" index_5 = str.find(';',index_4)\n",
" parameter = str[0:index_1]\n",
" value = str[index_2:index_3]\n",
" timestamp = str[index_5:] \n",
" return parameter,value,timestamp\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mv:\\georg\\Documents\\Persönliche Dokumente\\Arbeit\\Kelag\\Coding\\Python\\DT_Slot_3\\Kelag_DT_Slot_3\\Validation Data\\read_validation_data_long.ipynb Cell 3\u001b[0m in \u001b[0;36m<cell line: 7>\u001b[1;34m()\u001b[0m\n\u001b[0;32m <a href='vscode-notebook-cell:/v%3A/georg/Documents/Pers%C3%B6nliche%20Dokumente/Arbeit/Kelag/Coding/Python/DT_Slot_3/Kelag_DT_Slot_3/Validation%20Data/read_validation_data_long.ipynb#W1sZmlsZQ%3D%3D?line=5'>6</a>\u001b[0m timestamp_old \u001b[39m=\u001b[39m \u001b[39m0.\u001b[39m\n\u001b[0;32m <a href='vscode-notebook-cell:/v%3A/georg/Documents/Pers%C3%B6nliche%20Dokumente/Arbeit/Kelag/Coding/Python/DT_Slot_3/Kelag_DT_Slot_3/Validation%20Data/read_validation_data_long.ipynb#W1sZmlsZQ%3D%3D?line=6'>7</a>\u001b[0m \u001b[39mwith\u001b[39;00m \u001b[39mopen\u001b[39m(\u001b[39m'\u001b[39m\u001b[39mAugust_1_22.txt\u001b[39m\u001b[39m'\u001b[39m) \u001b[39mas\u001b[39;00m txt_file:\n\u001b[1;32m----> <a href='vscode-notebook-cell:/v%3A/georg/Documents/Pers%C3%B6nliche%20Dokumente/Arbeit/Kelag/Coding/Python/DT_Slot_3/Kelag_DT_Slot_3/Validation%20Data/read_validation_data_long.ipynb#W1sZmlsZQ%3D%3D?line=7'>8</a>\u001b[0m \u001b[39mfor\u001b[39;00m line \u001b[39min\u001b[39;00m txt_file:\n\u001b[0;32m <a href='vscode-notebook-cell:/v%3A/georg/Documents/Pers%C3%B6nliche%20Dokumente/Arbeit/Kelag/Coding/Python/DT_Slot_3/Kelag_DT_Slot_3/Validation%20Data/read_validation_data_long.ipynb#W1sZmlsZQ%3D%3D?line=8'>9</a>\u001b[0m parameter_new, value_new, timestamp_new \u001b[39m=\u001b[39m unpack_line(line)\n",
"File \u001b[1;32mc:\\Users\\georg\\anaconda3\\envs\\DT_Slot_3\\lib\\encodings\\cp1252.py:22\u001b[0m, in \u001b[0;36mIncrementalDecoder.decode\u001b[1;34m(self, input, final)\u001b[0m\n\u001b[0;32m 21\u001b[0m \u001b[39mclass\u001b[39;00m \u001b[39mIncrementalDecoder\u001b[39;00m(codecs\u001b[39m.\u001b[39mIncrementalDecoder):\n\u001b[1;32m---> 22\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mdecode\u001b[39m(\u001b[39mself\u001b[39m, \u001b[39minput\u001b[39m, final\u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m):\n\u001b[0;32m 23\u001b[0m \u001b[39mreturn\u001b[39;00m codecs\u001b[39m.\u001b[39mcharmap_decode(\u001b[39minput\u001b[39m,\u001b[39mself\u001b[39m\u001b[39m.\u001b[39merrors,decoding_table)[\u001b[39m0\u001b[39m]\n",
"\u001b[1;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"df = pd.DataFrame(columns=['Timestamp','M1-LA','M1-Druck','M2-LA','M2-Druck'])\n",
"\n",
"\n",
"parameter_old = ''\n",
"value_old = 0.\n",
"timestamp_old = 0.\n",
"value_list = []\n",
"timestamp_list = []\n",
"with open('August_1_22.txt') as txt_file:\n",
" for line in txt_file:\n",
" parameter_new, value_new, timestamp_new = unpack_line(line)\n",
" if parameter_new != parameter_old:\n",
" if parameter_old islike \"\"\n",
" \n",
" value_list = []\n",
" timestamp_list = []\n",
"\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.13 ('DT_Slot_3')",
"language": "python",
"name": "python3"
},
"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.13"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "4a28055eb8a3160fa4c7e4fca69770c4e0a1add985300856aa3fcf4ce32a2c48"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}