How do I convert .blf data from CAN to .csv using python

后端 未结 1 1400
半阙折子戏
半阙折子戏 2021-01-14 07:19

I have CAN-Data in the blf-format from the Vector software. For further investigation I want to convert it into csv format using python.

My progress so far:

相关标签:
1条回答
  • 2021-01-14 07:47

    List of that object does the trick

    import can
    import csv
    
    filename = "test.blf"
    log = can.BLFReader("test.blf")
    log = list(log)
    
    log_output = []
    
    for msg in log:
        msg = str(msg)
        log_output.append([msg[18:26],msg[38:40],msg[40:42],msg[46],msg[62],msg[67:90]])
    
    with open("output.csv", "w", newline='') as f:
        writer = csv.writer(f,delimiter=';', quotechar='\"', quoting=csv.QUOTE_ALL)
        writer.writerows(log_output)
    
    0 讨论(0)
提交回复
热议问题