Original answer:
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)
New answer:
Since I've posted this I actually created a library which provides a pandas like API for CAN data. Check it out here. A demonstration of features can be found here.
- Common format for dealing with CAN data
- Enrich plots of the logging data with data from the dbc files automatically
- Versatile and extensible plotting functions for all kinds of signals
- Easily export CAN data to a pandas dataframe
import candas as cd
db = cd.load_dbc("dbc_folder")
# Provide file without extension
log_data = cd.from_file("blf_file")
# Signals can be accessed like this
log_data["AVGcellTemperature"]