ratal / mdfreader

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

Index problem #196

Open jingyuan1994 opened 3 years ago

jingyuan1994 commented 3 years ago

Python version

3.8.3 (default, May 19 2020, 06:50:17) [MSC v.1916 64 bit (AMD64)]

Platform information

Windows-10-10.0.17134-SP0

Numpy version

1.19.0

mdfreader version

4.1

Description

There is an unusual problem happened. I got 2 MDF files which recorded by DataLogger, one of them could be read well but the other one reported a bug

File "D:/program/12222.py", line 20, in dt = mdfreader.Mdf('Data2F002Data2F002.mdf') File "D:\Anaconda\envs\test\Lib\site-packages\mdfreader\mdf.py", line 150, in init self.read(file_name, channel_list=channel_list, File "D:\Anaconda\envs\test\Lib\site-packages\mdfreader\mdfreader.py", line 409, in read self.read3(self.fileName, None, multi_processed, channel_list, File "D:\Anaconda\envs\test\Lib\site-packages\mdfreader\mdf3reader.py", line 947, in read3 buf.read(channel_set, self.fileName) # reads datablock potentially containing several channel groups File "D:\Anaconda\envs\test\Lib\site-packages\mdfreader\mdf3reader.py", line 702, in read data = self.load_unsorted(name_set=channel_set) File "D:\Anaconda\envs\test\Lib\site-packages\mdfreader\mdf3reader.py", line 773, in load_unsorted buf[channel_name][index[record_id]] = self.fid.read(nBytes[channel_name]) IndexError: index 18 is out of bounds for axis 0 with size 18

I try to fix it but I got no idea of changing the length of index. Following image is the details of my data. Hope you could help me to fix it. Thanks!

debug

ratal commented 3 years ago

Hi, sorry for the delay, I was in vacation. You are trying to read an unsorted file version 3.x.. I must admit it is not greatly tested. Thanks for sharing the screenshot. However, if I cannot compare with what is expected, like record structure from MDFValidator, it is too complex for me to troubleshoot. Or you can share the file if you can ; if you want to remove confidential info, you can scramble it following the script from Daniel : https://github.com/ratal/mdfreader/issues/189#issuecomment-711626428