ratal / mdfreader

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

mdf read issue #36

Closed swoldetsadick closed 7 years ago

swoldetsadick commented 7 years ago

KeyError Traceback (most recent call last)

in () ----> 1 data = mdfreader.mdf('C:/Users/q400300/Desktop/horor/measures_10.11.2016_14_20_32.mf4') C:\Users\q400300\Desktop\work\mdf.pyc in __init__(self, fileName, channelList, convertAfterRead, filterChannelNames) 104 self.fileName = fileName 105 if fileName is not None: --> 106 self.read(fileName, channelList=channelList, convertAfterRead=convertAfterRead, filterChannelNames=filterChannelNames) 107 108 C:\Users\q400300\Desktop\work\mdfreader.pyc in read(self, fileName, multiProc, channelList, convertAfterRead, filterChannelNames) 345 346 # read file blocks --> 347 info = mdfinfo(self.fileName, filterChannelNames) 348 349 self.MDFVersionNumber = info.mdfversion C:\Users\q400300\Desktop\work\mdfreader.pyc in __init__(self, fileName, filterChannelNames) 147 self.mdfversion = 0 148 if fileName is not None: --> 149 self.readinfo(fileName, filterChannelNames) 150 151 def readinfo(self, fileName=None, filterChannelNames=False): C:\Users\q400300\Desktop\work\mdfreader.pyc in readinfo(self, fileName, filterChannelNames) 180 else: # MDF version 4.x 181 from mdfinfo4 import info4 --> 182 self.update(info4(None, fid)) 183 184 def listChannels(self, fileName=None): C:\Users\q400300\Desktop\work\mdfinfo4.py in __init__(self, fileName, fid) 1148 fid.close() 1149 elif fileName is None and fid is not None: -> 1150 self.readinfo(fid) 1151 1152 def readinfo(self, fid): C:\Users\q400300\Desktop\work\mdfinfo4.py in readinfo(self, fid) 1195 1196 # reads Data Group Blocks and recursively the other related blocks -> 1197 self.readDGBlock(fid) 1198 1199 def readDGBlock(self, fid, channelNameList=False): C:\Users\q400300\Desktop\work\mdfinfo4.py in readDGBlock(self, fid, channelNameList) 1218 self['DGBlock'][dg].update(DGBlock(fid, self['DGBlock'][dg - 1]['dg_dg_next'])) 1219 # reads Channel Group blocks -> 1220 self.readCGBlock(fid, dg, channelNameList) 1221 1222 def readCGBlock(self, fid, dg, channelNameList=False): C:\Users\q400300\Desktop\work\mdfinfo4.py in readCGBlock(self, fid, dg, channelNameList) 1252 if not self['CGBlock'][dg][cg]['cg_flags'] & 0b1: # if not a VLSD channel group 1253 # reads Channel Block -> 1254 self.readCNBlock(fid, dg, cg, channelNameList) 1255 else: 1256 VLSDCGBlock.append(cg) C:\Users\q400300\Desktop\work\mdfinfo4.py in readCNBlock(self, fid, dg, cg, channelNameList) 1402 1403 # reads Channel Conversion Block -> 1404 self['CCBlock'][dg][cg][cn] = CCBlock(fid, self['CNBlock'][dg][cg][cn]['cn_cc_conversion']) 1405 1406 MLSDChannels = self.readComposition(fid, dg, cg, MLSDChannels, channelNameList=False) C:\Users\q400300\Desktop\work\mdfinfo4.py in __init__(self, fid, pointer) 818 def __init__(self, fid=None, pointer=None): 819 if fid is not None: --> 820 self.read(fid, pointer) 821 822 def read(self, fid, pointer): C:\Users\q400300\Desktop\work\mdfinfo4.py in read(self, fid, pointer) 855 elif ID in ('##CC', b'##CC'): # for table conversion 856 # much more complicated nesting conversions !!! --> 857 self['cc_ref'][i] = CCBlock(fid, self['cc_ref'][i])['name']['Comment'] 858 if self['cc_md_comment']: # comments exist 859 self['Comment'] = CommentBlock(fid, self['cc_md_comment'], MDType='CC') KeyError: 'name'
ratal commented 7 years ago

Hi, I see you also linked it to error #27 Indeeded it could be related. I think you can simply remove ['name']['Comment']. However, there might be some errors later trying to convert channels based on these nested channel conversions or wrong conversion : it was not properly implemented from a first look. It would help if you could open your file with MDF validator from Vector and try to see how your conversion blocks are nested. In the mean time I will work on a proper implementation of this nesting.

swoldetsadick commented 7 years ago

Hi, So I simply removed it as suggested it does run now and I can see my data. I will have to compare to actual canope output tomorrow. I will post result. Love this package by the way.

swoldetsadick commented 7 years ago

Hi, I will be investigating tomorrow if this is a real problem or if it is a problem coming from the tool that created the MDF data. It is possible. I got errors on the same fields when using turbo labs c++ libs. It says that the right conversion has not been specified. Keeping you posted.

swoldetsadick commented 7 years ago

It seems like CANOPE is messing some things up when writing nested MDF files. I have problems with files generated with this specific software. So I will now close this issue.