I’d say
chunks = [data[x:x+100] for x in range(0, len(data), 100)]
If you are using python 2.x instead of 3.x, you can be more memory-efficient by using xrange()
, changing the above code to:
chunks = [data[x:x+100] for x in xrange(0, len(data), 100)]
More Related Contents:
- how to parse the response in python?
- How to add a label to all words in a file? [closed]
- Python 2.7 IndentationError [closed]
- How to rename a file in python
- How to detect key presses?
- Using both Python 2.x and Python 3.x in IPython Notebook
- Convert string to variable name in python [duplicate]
- What do ellipsis […] mean in a list?
- Pelican 3.3 pelican-quickstart error “ValueError: unknown locale: UTF-8”
- Getting attributes of a class
- pip or pip3 to install packages for Python 3?
- Installing Numpy on 64bit Windows 7 with Python 2.7.3 [closed]
- file.tell() inconsistency
- operator.itemgetter or lambda
- Error importing hashlib with python 2.7 but not with 2.6
- Linux command-line call not returning what it should from os.system?
- Surprising results with Python timeit: Counter() vs defaultdict() vs dict()
- How do I run python 2 and 3 in windows 7? [duplicate]
- BeautifulSoup returns empty list when searching by compound class names
- Is Python’s order of evaluation of function arguments and operands deterministic (+ where is it documented)?
- Get Excel-Style Column Names from Column Number
- xlsx and xlsm files return badzipfile: file is not a zip file
- Group DataFrame in 5-minute intervals
- How to draw rectangle outside of the plot frame in Matplotlib
- How to create a new text file using Python
- Python: How to resize an image using PIL module
- Python not able to open file with non-english characters in path
- How to fix TypeError: ‘int’ object is not subscriptable
- Elegant way to perform tuple arithmetic
- ‘is’ operator behaves unexpectedly with floats