Skip to content

Commit

Permalink
Fix seek in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreeve committed Apr 3, 2020
1 parent 2d3feab commit 4050199
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions nptdms/base_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,11 @@ def read_raw_data_for_channel(self, f, channel_path, chunk_offset=0, num_chunks=
data_objects = [o for o in self.ordered_objects if o.has_data]
chunk_size = self._get_chunk_size()

for chunk_index in range(self.num_chunks):
if chunk_index < chunk_offset:
f.seek(chunk_size, os.SEEK_CUR)
elif num_chunks is None or chunk_index < num_chunks + chunk_offset:
yield self._read_channel_data_chunk(f, data_objects, chunk_index, channel_path)
else:
break
if chunk_offset > 0:
f.seek(chunk_size * chunk_offset, os.SEEK_CUR)
stop_chunk = self.num_chunks if num_chunks is None else num_chunks + chunk_offset
for chunk_index in range(chunk_offset, stop_chunk):
yield self._read_channel_data_chunk(f, data_objects, chunk_index, channel_path)

def _calculate_chunks(self):
"""
Expand Down

0 comments on commit 4050199

Please sign in to comment.