def chunk_index_list(indices):
 chunks = []
 chunk = ''
 for index in indices:
  if (len(chunk) < 3072):
   if (not chunk):
    chunk = index
   else:
    chunk += (',' + index)
  else:
   chunks.append(chunk.split(','))
   chunk = index
 chunks.append(chunk.split(','))
 return chunks

def chunk_index_list ( indices ) : chunks = [ ] chunk = '' for index in indices : if ( len ( chunk ) < 3072 ) : if ( not chunk ) : chunk = index else : chunk += ( ',' + index ) else : chunks . append ( chunk . split ( ',' ) ) chunk = index chunks . append ( chunk . split ( ',' ) ) return chunks
this utility chunks very large index lists into 3kb chunks it measures the size as a csv string .