12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import re
- import pandas as pd
- import pickle
- def save(object_to_save, path):
- '''
- 保存对象
- @Arugs:
- object_to_save: 需要保存的对象
- @Return:
- 保存的路径
- '''
- with open(path, 'wb') as f:
- pickle.dump(object_to_save, f)
- def extract_uuid_from_log():
- list_files = [
- "/data/python/flow_init_log/flow_init_2022-06-02.log",
- "/data/python/flow_init_log/flow_init_2022-06-03.log",
- "/data/python/flow_init_log/flow_init_2022-06-04.log",
- "/data/python/flow_init_log/flow_init_2022-06-05.log",
- "/data/python/flow_init.log"
- ]
- list_uuid = []
- _regrex = "delete\s+(?P<tablename>bxkc[^\s]+)\s+.*ID='(?P<uuid>.+)'"
- for _file in list_files:
- with open(_file,"r",encoding="utf8") as f:
- while 1:
- _line = f.readline()
- if not _line:
- break
- _match = re.search(_regrex,_line)
- if _match is not None:
- _uuid = _match.groupdict().get("uuid")
- tablename = _match.groupdict().get("tablename")
- if _uuid is not None:
- list_uuid.append({"uuid":_uuid,"tablename":tablename})
- df_data = {"uuid":[],
- "tablename":[]}
- for _data in list_uuid:
- for k,v in df_data.items():
- v.append(_data.get(k))
- save(df_data,"uuid.pk")
- if __name__ == '__main__':
- extract_uuid_from_log()
|