Skip to content

Commit

Permalink
mdf4reader: solved bug for VLSD SDBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
aymeric.rateau@gmail.com committed Feb 7, 2015
1 parent 4ec15a5 commit 55ccfb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions mdf4reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
--------------------------
"""
from numpy.core.records import fromrecords, fromstring, fromfile
from numpy.core.records import fromstring, fromfile
from numpy import array, recarray, append, asarray, empty, zeros, dtype, where
from numpy import arange, right_shift, bitwise_and, all, diff, interp
from struct import unpack, Struct
Expand Down Expand Up @@ -95,19 +95,15 @@ def DATABlock(record, parent_block, channelList=None, sortedFlag=True):
format='>utf-16'
pointer=0
buf=[] # buf=array(record.numberOfRecords,dtype='s'+str(record.maxLengthVLSDRecord))
nElement=0

while pointer<parent_block['length']-24:
VLSDLen=unpack('I', parent_block['data'][pointer:pointer+4])[0] # length of data
pointer+=4
buf.append(parent_block['data'][pointer:pointer+VLSDLen].decode(format).rstrip('\x00')) # to be improved, removing append
#buf[nElement]=fid.read(VLSDLen).decode(format).rstrip('\x00')
pointer+=VLSDLen
nElement+=1
if nElement>1:
buf=equalizeStringLength(buf)
return fromrecords(buf, names=str(record.name))
else: # only one data
return buf
buf=equalizeStringLength(buf)
return array(buf)

elif parent_block['id'] in ('##DZ', b'##DZ'): # zipped data block
# uncompress data
Expand Down
Binary file modified mdfreader.pdf
Binary file not shown.

0 comments on commit 55ccfb4

Please sign in to comment.