The log exported via canoe usually has many IDs of data, how can I find a special signal under an ID? Using Python, you can simply do this step with the following code:
Description
The final effect is to split the log information, separate the IDs, and generate the file Log_id.csv folder separately.
1. Input folder required
2. Generate the _out folder.
3. No error handling
4. Use "[A-f|\d]{3}" to match the can ID
1 #log analy about CAN Signal for CANOE2 ImportOS3 ImportRe4 5Id_info = {}6fold_in = input ("Please input Folder in:")7Fold_out = fold_in +"_out"8 Os.mkdir (fold_out)9rep_id = R"[A-f|\d]{3}"Tenpatt_id =re.compile (rep_id) One defInfo_report (): A " " - The information in the CAN log has a fixed number of digits. - 0: Time stamp the 1:1/2 - 2:id - 3:rx/tx - 4:d + 5:data Length - 6:data Length Number info + " " A Pass at - defDev_folder (folder_in): - forFiinchOs.listdir (folder_in): - #Open File -With open (Os.path.join (FOLDER_IN,FI),"R") as file: - #traversing file Lines in forLineinchFile: - #split the file, remove the space, remove the comma before and after toA = Re.sub ('\s+',',', line). Strip (",") + #determines whether the list has more than 3 elements, and whether the 3rd is an ID. - ifLen (A.split (",")) > 2 andPatt_id.match (A.split (",") [2]): the ifA.split (",") [2]inchId_info.keys (): * #If you are in the dictionary, write the information directly to the file $ PassPanax Notoginseng Else: - #Create a new file, associate a dictionary theId_info[a.split (",") [2]] = open ((Os.path.join (Fold_out +"\\"+"Log_"+ A.split (",") [2]) +". csv"),"W") +Id_info[a.split (",") [2]].write (A +"\ n") A #Print (A.split (",") [0]) the forKeyinchId_info: + id_info[key].close () - $ if __name__=='__main__': $ Dev_folder (fold_in) -
Python split Canlog