zele-utils/functions/helpers.py

16 lines
491 B
Python
Raw Normal View History

2024-09-10 17:40:50 -04:00
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)