我有一个脚本,用于分析PLC标记并读取许多标记,非常多。我想知道如何将打印输出保存为带表格格式的Excel文件。
这是脚本的一部分。
with PLC() as comm:
comm.IPAddress = '192.168.100.5'
comm.ProcessorSlot = 0
ret = comm.GetPLCTime()
print("Fecha y Hora de Registro Revision Fallas", ret.Value)
time.sleep(1)
Estacion = "D2M017"
#ACTUADOR 1
ACTUADOR = comm.Read('D2M_017.Status.Act._1.WBypassed')
ret = comm.GetPLCTime()
Numero_Act_EnBypass = 0
if ACTUADOR.Value == True:
Sensor = "ACTUADOR 1 WORK SENSOR EN BY PASS"
Numero_Act_EnBypass = (Numero_Act_EnBypass +1)
print(Estacion, ret.Value, "D2M017 =",Sensor)
else:
Sensor = "ACTUADOR 1 WORK OK"
ACTUADOR = comm.Read('D2M_017.Status.Act._1.HBypassed')
ret = comm.GetPLCTime()
if ACTUADOR.Value == True:
Sensor = "ACTUADOR 1 HOME SENSOR EN BY PASS"
Numero_Act_EnBypass = (Numero_Act_EnBypass +1)
print(Estacion, ret.Value, "D2M017 =",Sensor)
else:
Sensor = "ACTUADOR 1 HOME OK"
此部分重复了64次,并最终得到以下结果:
我需要将该信息保存到Excel表格中,并分割成以下部分:站点、日期、状态。