Skip to content

Commit 4a186af

Browse files
authored
Merge pull request #44 from DavidStirling/ranging
Constrain automatic row range to table limit
2 parents ef210ae + 257f578 commit 4a186af

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

omero2pandas/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ def read_table(file_id=None, annotation_id=None, column_names=(), rows=None,
171171
# Download data
172172
for start in range(0, num_rows, chunk_size):
173173
if rows is None:
174-
data = data_table.read(target_cols, start, start + chunk_size)
174+
end = min(start + chunk_size, num_rows)
175+
data = data_table.read(target_cols, start, end)
175176
else:
176177
data = data_table.slice(target_cols,
177178
rows[start:start + chunk_size])
@@ -344,7 +345,8 @@ def download_table(target_path, file_id=None, annotation_id=None,
344345
for start in range(0, num_rows, chunk_size):
345346
data_buffer = {}
346347
if rows is None:
347-
data = data_table.read(target_cols, start, start + chunk_size)
348+
end = min(start + chunk_size, num_rows)
349+
data = data_table.read(target_cols, start, end)
348350
else:
349351
data = data_table.slice(target_cols,
350352
rows[start:start + chunk_size])

0 commit comments

Comments
 (0)