dxchange icon indicating copy to clipboard operation
dxchange copied to clipboard

UnboundLocalError in _read_ole_data when reading txrm file

Open djorlando24 opened this issue 7 years ago • 0 comments

This bug is in the version of dxchange obtained through conda, I have not checked if the current version on github has the same issue.

When reading a TXRM file generated by an XRadia machine using dxchange.read_txrm, I get UnboundLocalError: local variable 'arr' referenced before assignment

This is occurring because sometimes containers in the TXRM file can be empty. I solved the problem by modifying dxchange/reader.py to return None when the container is empty. On line 906 of reader.py;

if ole.exists(label):
        stream = ole.openstream(label)
        data = stream.read()
        arr = struct.unpack(struct_fmt, data)
        return arr
else:
        return None

djorlando24 avatar Jan 24 '18 05:01 djorlando24