[英]How to plot the output from regular expression?
我試圖顯示一組來自正則表達式的數據,而不是繪制它們。 我使用此功能顯示我的數據
def loadInfoFrom_Node_Own_Synchronization_signals_List(logFile, signal_sync):
fsrc = open(logFile, 'r')
buff = fsrc.read()
fsrc.close()
list_info = re.findall(signal_sync, buff)
print('list_info= '+str(list_info))
print('list_info_length= '+str(len(list_info)))
dict_node_info = {}
init_time = None
for timestamp, id_src_node, Counter in list_info:
if init_time == None:
init_time = float(timestamp)
if id_src_node not in dict_node_info:
dict_node_info[id_src_node] = {"timestamp": [float(timestamp) - init_time],
'Counter': [int(Counter)]}
else:
dict_node_info[id_src_node]["timestamp"].append(float(timestamp) - init_time)
dict_node_info[id_src_node]["Counter"].append(int(Counter))
return dict_node_info
正則表達式結果集如下所示:
list_info= [('1547226386', '02141592cc00000001', '1'), ('1547226386', '02141592cc00000001', '2'), ('1547226387', '02141592cc00000001', '3'), ('1547226388', '02141592cc00000001', '4'), ('1547226388', '02141592cc00000001', '5'), ('1547226390', '02141592cc00000001', '6'), ('1547226392', '02141592cc00000004', '7'), ('1547226392', '02141592cc00000001', '8'), ('1547226393', '02141592cc00000004', '9'), ('1547226393', '02141592cc00000001', '10'), ('1547226394', '02141592cc00000001', '11'), ('1547226395', '02141592cc00000001', '12'), ('1547226395', '02141592cc00000001', '13'), ('1547226397', '02141592cc00000001', '14'), ('1547226398', '02141592cc00000001', '15'), ('1547226398', '02141592cc00000004', '16'), ('1547226399', '02141592cc00000004', '17'), ('1547226399', '02141592cc00000001', '18'), ('1547226400', '02141592cc00000004', '19')]
但是,我的函數的結果僅返回此結果
dict_node_info= {'02141592cc00000001': {'Counter': [1], 'timestamp': [0.0]}}
結果,我有一個空圖;需要繪制正則表達式的所有輸出的時間。
return dict_node_info
語句向右縮進太遠,使函數在第一次迭代后返回-可能不是您想要的。 向左縮進語句,看是否有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.