Openpyxl dejó de funcionar
Publicado por Sergio (4 intervenciones) el 16/09/2019 04:13:39
Hola a todos.
Elaboré el siguiente script y cuando lo probé las primeras veces funcionó todo bien incluyendo el registro de los datos en una hoja de excel. Días después abrí nuevamente el script y ya no actualizó ninguna información en la hoja de excel.
Qué puede haber pasado? Estoy usando Pychon 2.7.
Este es mi script.
Elaboré el siguiente script y cuando lo probé las primeras veces funcionó todo bien incluyendo el registro de los datos en una hoja de excel. Días después abrí nuevamente el script y ya no actualizó ninguna información en la hoja de excel.
Qué puede haber pasado? Estoy usando Pychon 2.7.
Este es mi script.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import RPi.GPIO as GPIO
from time import sleep
from datetime import datetime
from time import time
from openpyxl import load_workbook
from Tkinter import *
filesheet="./demosheet.xlsx"
wb=load_workbook(filesheet)
sheet=wb.active
count=0
tiempo_total=0
hay_presencia=0
habia_presencia=0
t=round(time(),3)
takt=0
tiempo_total=0
tiempo_promedio=0
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.IN)
hora_arranque=t
tiempo_inicio=t
raiz=Tk()
raiz.title("Triton Control")
#raiz.geometry("300x900")
raiz.config(bg="blue")
raiz.resizable(0,0)
frame1=Frame()
frame1.config(width="300", height="900")
frame1.pack()
frame1.config(bg="cornsilk4")
#frame1.geometry("300x900")
frame1.config(bd=10)
frame1.config(relief="groove")
Label(frame1, text="Cantidad de pliegos producidos:").grid(row=0, column=1, sticky=W, pady=4, padx=4)
Label(frame1, text=(count)).grid(row=0, column=2, sticky=E, pady=4, padx=4)
Label(frame1, text="TAKT TIME:").grid(row=1, column=1, sticky=W, pady=4, padx=4)
Label(frame1, text=(takt)).grid(row=1, column=2, sticky=E, pady=4, padx=4)
Label(frame1, text="Tiempo promedio por pliego:").grid(row=2, column=1, sticky=W, pady=4, padx=4)
Label(frame1, text=(tiempo_promedio)).grid(row=2, column=2, sticky=E, pady=4, padx=4)
Label(frame1, text="Tiempo total en producción:").grid(row=3, column=1,sticky=W, pady=4, padx=4)
Label(frame1, text=(tiempo_total)).grid(row=3, column=2, sticky=E, pady=4, padx=4)
while True:
raiz.update()
sensor=GPIO.input(24)
# sleep(0.1)
if sensor==0: # con presencia
hay_presencia=1
if hay_presencia==1:
if habia_presencia==0:
count=count+1
tiempo_final=round(time(),3)
takt=round(tiempo_final-tiempo_inicio,3)
tiempo_total=round(tiempo_total+takt,3)
tiempo_promedio=round(tiempo_total/count,3)
# print('Numero de pliegos: '+str(count),'Takt:'+str(takt),'Tiempo_total:'+str(tiempo_total),'Tiempo promedio:'+str(tiempo_promedio))
datos=(count, takt, tiempo_total, tiempo_promedio)
print(datos)
sheet.append(datos)
# print('Guardando datos')
wb.save(filesheet)
# print('Guardando filesheet')
tiempo_inicio=tiempo_final
habia_presencia=1
Label(frame1, text="Cantidad de pliegos producidos:").grid(row=0, column=1, sticky=W, pady=4, padx=4)
Label(frame1, text=(count)).grid(row=0, column=2, sticky=E, pady=4, padx=4)
Label(frame1, text="TAKT TIME:").grid(row=1, column=1, sticky=W, pady=4, padx=4)
Label(frame1, text=(takt)).grid(row=1, column=2, sticky=E, pady=4, padx=4)
Label(frame1, text="Tiempo promedio por pliego:").grid(row=2, column=1, sticky=W, pady=4, padx=4)
Label(frame1, text=(tiempo_promedio)).grid(row=2, column=2, sticky=E, pady=4, padx=4)
Label(frame1, text="Tiempo total en producción:").grid(row=3, column=1,sticky=W, pady=4, padx=4)
Label(frame1, text=(tiempo_total)).grid(row=3, column=2, sticky=E, pady=4, padx=4)
elif sensor==1: # sin presencia
habia_presencia=0
Valora esta pregunta


0