danielhrisca / asammdf

Fast Python reader and editor for ASAM MDF / MF4 (Measurement Data Format) files
GNU Lesser General Public License v3.0
612 stars 216 forks source link

UnboundLocalError: cannot access local variable 'new_values' where it is not associated with a value #934

Closed matjoh98 closed 8 months ago

matjoh98 commented 8 months ago

Python version

'python=3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]' 'os=Windows-10-10.0.19045-SP0' 'numpy=1.23.4' 'asammdf=7.3.17'

Code

MDF version

3.0

Code snippet

import asammdf

data = asammdf.MDF("data/mdf3_0.mdf")
data = data.resample(1).to_dataframe(ignore_value2text_conversions=True)

Traceback

Traceback (most recent call last): File "c:\Users\a373150\Desktop\Scripts\asammdf\main.py", line 9, in data2 = data2.resample(1).to_dataframe(ignore_value2text_conversions=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\a373150\AppData\Local\Programs\Python\Python311\Lib\site-packages\asammdf\mdf.py", line 4417, in to_dataframe samples = conversion.convert( ^^^^^^^^^^^^^^^^^^^ File "C:\Users\a373150\AppData\Local\Programs\Python\Python311\Lib\site-packages\asammdf\blocks\v2_v3_blocks.py", line 1480, in convert values = new_values ^^^^^^^^^^ UnboundLocalError: cannot access local variable 'new_values' where it is not associated with a value

Description

Hi.

For asammdf=7.3.17, the _ignore_value2textconversions=True when opening a mdf=3.0 raises the UnboundLocalError. It works well with a mdf=4.10 though. I've used this method previously and it worked fine with different mdf versions as well.

I've tried the following versions where this method breaks: asammdf=7.3.17 asammdf=7.3.16 asammdf=7.3.15

But it works with this one: asammdf=7.3.14

danielhrisca commented 8 months ago

@matjoh98 please try the development branch code

matjoh98 commented 8 months ago

Thanks, works well now!