ratal / mdfreader

Read Measurement Data Format (MDF) versions 3.x and 4.x file formats in python
Other
169 stars 73 forks source link

UnboundLocalError: local variable 'record_size' referenced before assignment #214

Closed NageshKumarGowda closed 1 month ago

NageshKumarGowda commented 1 month ago

Python version

Python 3.10.0

Platform information

Windows

Numpy version

1.24.4

mdfreader version

Description

This is a small bug in asammdf\blocks\mdf_v4.py, we should initialize the record_size to 0 in case the MDF is reading an empty mf4 files or else we will get the following error

Traceback (most recent call last): File "D:\Docker\ARS540DP14_reprocessing_system\test.py", line 3, in data = MDF(r'D:\Docker\BW27\2024-04-23_12-39-24_2024-04-23_12-39-31_556495_9T56155_FRR_DEBUG_0000.MF4') File "C:\LegacyApp\Python\Python39\lib\site-packages\asammdf\mdf.py", line 350, in init self._mdf = MDF4(name, channels=channels, kwargs) File "C:\LegacyApp\Python\Python39\lib\site-packages\asammdf\blocks\mdf_v4.py", line 402, in init self._read(mapped=True, progress=progress) File "C:\LegacyApp\Python\Python39\lib\site-packages\asammdf\blocks\mdf_v4.py", line 669, in _read record_size=record_size**, UnboundLocalError: local variable 'record_size' referenced before assignment

image This solution can be used.

ratal commented 1 month ago

You posted in the wrong repo