Python:測試資料輸出到csv
阿新 • • 發佈:2021-12-14
測試目的
因專案需要,需要實現1-8個通道執行運動時,將獲取的gaps值記錄並輸出到csv檔案中,方便進行統計
測試程式碼
1 def test_loadTipGaps(): 2 """ 3 測試檯面及版本: 4 1)檯面檔案:TestDeck_V0.4_20211105.SPD(注意同步更新自定義載架的json檔案) 5 2)檯面編輯版本:V0.4_20211029_2 6 3)控制軟體版本:V0.4.0.15 7 測試目的:扎排吸頭壓力測試 8 測試場景: 9 1)可用於收集扎吸頭gaps10 2)也可用於扎吸頭硬體可靠性測試 11 """ 12 TipSequence = ["Lane7TipsPos1", "Lane7TipsPos2", "Lane7TipsPos3", "Lane7TipsPos4", "Lane7TipsPos5"] 13 with open("record_loads_gaps" + ".csv", "a") as f: 14 f.write("Time,Pos,Channel1,channel2,channel3,channel4,channel5,channel6,channel7,channel8\n") # titles 15 for j in range(200): 16 sp8Channels.WorkflowDeck.ReloadDeck() 17 for SequenceName in TipSequence: 18 for i in range(12): 19 load_tips({"Sequence": SequenceName, "Channels": [1, 2, 3, 4, 5, 6, 7, 8], "IfIncrement": False})20 current_time = time.strftime('%Y%m%d-%H%M%S', time.localtime(time.time())) 21 line = current_time + ',' + str(SequenceName) + base_action.Gaps 22 print(line) 23 f.write(line + "\n") 24 unload_tips({"Sequence": SequenceName, "Channels": [1, 2, 3, 4, 5, 6, 7, 8], "IfIncrement": True}) 25 time.sleep(0.5) 26 reload_sequences(["Lane7TipsPos1", "Lane7TipsPos2", "Lane7TipsPos3", "Lane7TipsPos4", "Lane7TipsPos5"]) 27 28 test_loadTipGaps()