mirror of
https://github.com/knejadshamsi/zele-utils.git
synced 2024-11-14 17:40:28 -05:00
16 lines
491 B
Python
16 lines
491 B
Python
|
def buffer_creator(file,divider,start_line, chunk_size):
|
||
|
buffer = []
|
||
|
line_number = start_line
|
||
|
current_line = 0
|
||
|
divider_count = 0
|
||
|
with open(file,'r',encoding='utf-8') as f:
|
||
|
for line in f:
|
||
|
current_line += 1
|
||
|
if (current_line <= line_number): continue
|
||
|
if (line.strip()== divider):
|
||
|
divider_count = divider_count + 1
|
||
|
if divider_count == chunk_size: break
|
||
|
continue
|
||
|
buffer.append(line.strip())
|
||
|
return current_line,(' ').join(buffer)
|
||
|
|