November 2015
Intermediate to advanced
304 pages
5h 23m
English
Chapter 30

1 #!/usr/bin/env python 2 import sys, re, operator, string 3 4 # 5 # Functions for map reduce 6 # 7 def partition(data_str, nlines): 8 """ 9 Partitions the input data_str (a big string) 10 into chunks of nlines. 11 """ 12 lines = data_str.split('\n') 13 for i in xrange(0, len(lines), nlines): 14 yield '\n'.join(lines[i:i+nlines]) 15 16 def ...