from itertools import chain, islice

def chunks(iterable, n):
    """chunks(ABCDE,2) => AB CD E"""
iterable = iter(iterable)
while True:
    yield chain([next(iterable)], islice(iterable, n - 1))
l = 30 * 10 ** 6
file_large = 'large_file.txt'
with open(file_large) as bigfile:
    for i, lines in enumerate(chunks(bigfile, l)):
        file_split = '{}.{}'.format(file_large, i)
with open(file_split, 'w') as f:
    f.writelines(lines)
Split large text file(around 50GB) into multiple files