Skip to content

Instantly share code, notes, and snippets.

@msymt
Last active June 4, 2023 05:50
Show Gist options
  • Save msymt/5ebd6a5d462797d5620c6b862442f596 to your computer and use it in GitHub Desktop.
Save msymt/5ebd6a5d462797d5620c6b862442f596 to your computer and use it in GitHub Desktop.
candumpのdumpファイルからcan idだけuniqueに抽出するpythonスクリプト
DUMP_FILE = "CANDUMP.log"
can_id_array = []
with open(DUMP_FILE, 'r') as f:
while True:
data = f.readline()
if not data:
break
sp_pivot = data.find('#')
can_id = data[sp_pivot - 3:sp_pivot]
# print(can_id)
can_id_array.append(can_id)
can_id_array_u = set(can_id_array)
print(can_id_array_u)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment