{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": { "metadata": {} }, "outputs": [], "source": [ "import os\n", "import cv2\n", "import xlsxwriter\n", "import numpy as np\n", "\n", "\n", "def shear_img(image):\n", " rows, cols, _ = image.shape\n", " M = np.float32([[1, -0.22, 0], [0, 1, 0], [0, 0, 1]])\n", " sheared_img = cv2.warpPerspective(image, M, (int(cols * 1.5), int(rows * 1.5)))\n", " return cv2.flip(sheared_img, 1)\n", "\n", "\n", "def crop_image(sheared_image, r, target_path):\n", " cropped = sheared_image[int(r[1]) : int(r[1] + r[3]), int(r[0]) : int(r[0] + r[2])]\n", " return cropped" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "metadata": {} }, "outputs": [], "source": [ "from datetime import datetime\n", "\n", "\n", "def writeDate(worksheet, row, column, date, format):\n", " original_format = \"%Y-%m-%d %H-%M-%S-%f\"\n", " parsed_datetime = datetime.strptime(date, original_format)\n", "\n", " worksheet.write_datetime(row, column, parsed_datetime, format)\n", "\n", "\n", "def data2excel(data):\n", " # save the data in an excel file\n", " fileName = \"data.xlsx\"\n", " workbook = xlsxwriter.Workbook(fileName)\n", " worksheet = workbook.add_worksheet()\n", "\n", " dateFormat = workbook.add_format({\"num_format\": \"dd/mm/yy hh:mm:ss\"})\n", "\n", " # write the data\n", " row = 0\n", " for key, value in data.items():\n", " date = key.split(\" \", 1)[1][:-4]\n", " writeDate(worksheet, row, 0, date, dateFormat)\n", " worksheet.write(row, 1, value)\n", " try:\n", " worksheet.write(row, 2, float(value[:6]))\n", " except Exception as _:\n", " pass\n", " row += 1\n", "\n", " workbook.close()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "metadata": {} }, "outputs": [], "source": [ "def peaks(data, boxes=2):\n", " # split data in boxes\n", " data = np.array_split(data, boxes)\n", "\n", " # get the maximum value in each box\n", " data = [np.max(d) for d in data]\n", " data = [d > 150 for d in data]\n", " return np.array(data).astype(int).tolist()\n", "\n", "\n", "digits = {\n", " 0: [[1, 0, 1], [1, 1], [1, 1]],\n", " 1: [[0, 0, 0], [0, 1], [0, 1]],\n", " 2: [[1, 1, 1], [0, 1], [1, 0]],\n", " 3: [[1, 1, 1], [0, 1], [0, 1]],\n", " 4: [[0, 1, 0], [1, 1], [0, 1]],\n", " 5: [[1, 1, 1], [1, 0], [0, 1]],\n", " 6: [[1, 1, 1], [1, 0], [1, 1]],\n", " 7: [[1, 0, 0], [0, 1], [0, 1]],\n", " 8: [[1, 1, 1], [1, 1], [1, 1]],\n", " 9: [[1, 1, 1], [1, 1], [0, 1]],\n", "}\n", "\n", "\n", "def ownOCR(image):\n", " # get vertical pixel line in the middle of the image\n", " vertical = image[:, image.shape[1] // 2, 0]\n", "\n", " # get two horizontal lines at 1/3 and 2/3 of the image\n", " horizontal1 = image[image.shape[0] // 3, :, 0]\n", " horizontal2 = image[2 * image.shape[0] // 3, :, 0]\n", "\n", " # get times it goes above 150, remove subsequent values\n", " digit = [peaks(vertical, 3), peaks(horizontal1), peaks(horizontal2)]\n", " digit = [key for key, value in digits.items() if value == digit]\n", " return digit[0]" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "metadata": {} }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "list index out of range\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n", "index 0 is out of bounds for axis 1 with size 0\n" ] }, { "ename": "KeyboardInterrupt", "evalue": "", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", "Cell \u001b[1;32mIn[5], line 24\u001b[0m\n\u001b[0;32m 22\u001b[0m image_path \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(folder, image_name)\n\u001b[0;32m 23\u001b[0m image \u001b[38;5;241m=\u001b[39m cv2\u001b[38;5;241m.\u001b[39mimread(image_path)\n\u001b[1;32m---> 24\u001b[0m sheared_image \u001b[38;5;241m=\u001b[39m \u001b[43mshear_img\u001b[49m\u001b[43m(\u001b[49m\u001b[43mimage\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 26\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m idx, region \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(regions):\n\u001b[0;32m 27\u001b[0m target_path \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(cropped_folder, \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mimage_name[:\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m4\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00midx\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m1\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.jpg\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", "Cell \u001b[1;32mIn[2], line 11\u001b[0m, in \u001b[0;36mshear_img\u001b[1;34m(image)\u001b[0m\n\u001b[0;32m 9\u001b[0m M \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mfloat32([[\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m0.22\u001b[39m, \u001b[38;5;241m0\u001b[39m], [\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m0\u001b[39m], [\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1\u001b[39m]])\n\u001b[0;32m 10\u001b[0m sheared_img \u001b[38;5;241m=\u001b[39m cv2\u001b[38;5;241m.\u001b[39mwarpPerspective(image, M, (\u001b[38;5;28mint\u001b[39m(cols \u001b[38;5;241m*\u001b[39m \u001b[38;5;241m1.5\u001b[39m), \u001b[38;5;28mint\u001b[39m(rows \u001b[38;5;241m*\u001b[39m \u001b[38;5;241m1.5\u001b[39m)))\n\u001b[1;32m---> 11\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcv2\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mflip\u001b[49m\u001b[43m(\u001b[49m\u001b[43msheared_img\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\n", "\u001b[1;31mKeyboardInterrupt\u001b[0m: " ] } ], "source": [ "folder = \"./wetransfer_metingen-16-04-1200-1300_2024-04-16_1102/metingen 16-04 (1200-1300)/\"\n", "images = [f for f in os.listdir(folder) if f.endswith(\".jpg\")]\n", "cropped_folder = os.path.join(folder, \"cropped\")\n", "os.makedirs(cropped_folder, exist_ok=True)\n", "\n", "# Initial image for ROI selection\n", "init_image_path = os.path.join(folder, images[0])\n", "init_image = cv2.imread(init_image_path)\n", "sheared_init_image = shear_img(init_image)\n", "\n", "regions = []\n", "for i in range(5): # Assume 5 regions as in your original code\n", " r = cv2.selectROI(f\"Select the digit {i+1}\", sheared_init_image)\n", " cv2.destroyAllWindows()\n", " regions.append(r)\n", "\n", "data = {}\n", "i = 0\n", "# Process all images\n", "for image_name in images:\n", " try:\n", " image_path = os.path.join(folder, image_name)\n", " image = cv2.imread(image_path)\n", " sheared_image = shear_img(image)\n", "\n", " for idx, region in enumerate(regions):\n", " target_path = os.path.join(cropped_folder, f\"{image_name[:-4]}_{idx+1}.jpg\")\n", " cropped = crop_image(sheared_image, region, target_path)\n", " digit = ownOCR(cropped)\n", "\n", " if image_name not in data:\n", " data[image_name] = \"\"\n", "\n", " data[image_name] += str(digit)\n", " except Exception as e:\n", " print(e)\n", " continue" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "metadata": {} }, "outputs": [], "source": [ "data2excel(data)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "metadata": {} }, "outputs": [], "source": [ "# clean excel file\n", "def data2cleanexcel(data):\n", " # save the data in an excel file\n", " fileName = \"data_clean.xlsx\"\n", " workbook = xlsxwriter.Workbook(fileName)\n", " worksheet = workbook.add_worksheet()\n", "\n", " dateFormat = workbook.add_format({\"num_format\": \"dd/mm/yy hh:mm:ss\"})\n", "\n", " # write the data\n", " row = 0\n", " for key, value in data.items():\n", " try:\n", " value = \"6\"+value[1:]\n", " worksheet.write(row, 2, float(value[:6]))\n", " date = key.split(\" \", 1)[1][:-4]\n", " writeDate(worksheet, row, 0, date, dateFormat) \n", " worksheet.write(row, 1, value)\n", " except Exception as _:\n", " continue\n", "\n", " row += 1\n", "\n", " workbook.close()\n", "\n", "\n", "data2cleanexcel(data)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 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.10.14" } }, "nbformat": 4, "nbformat_minor": 2 }