How do I convert .blf data of CAN to .asc using python

Solution 1:

Very similar to my other answer you should read your blf file in binary mode then write the messages in the asc one:

import can

with open(blf_file, 'rb') as f_in:
    log_in = can.io.BLFReader(f_in)

    with open("file_out.asc", 'w') as f_out:
        log_out = can.io.ASCWriter(f_out)
        for msg in log_in:
            log_out.on_message_received(msg)
        log_out.stop()