Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@amka
Created October 13, 2016 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amka/dae2defe0d78e48132168343d35fa6d1 to your computer and use it in GitHub Desktop.
Save amka/dae2defe0d78e48132168343d35fa6d1 to your computer and use it in GitHub Desktop.
def get_chunk(sequence, chunk_size=100, limit=None):
count = 0
offset = 0
length = len(sequence)
if not limit:
limit = length
while count < limit and offset < length:
yield sequence[offset:chunk_size + offset]
count += 1
offset += chunk_size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment