Working to separate a single long text file into multiple files. Each section that needs to be placed into its own file, is separated by hyphen lines that look something like:
This is section of some sample text
that says something.
2---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This says something else
3---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Maybe this says something eles
4---------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
I have started the attempt in python without much success. I considered using the split fnx but I'm finding most examples provided for the split fnx revolve around len rather than regex type characters. This only generates one large file.
with open ('someName.txt','r') as fo:
start=1
cntr=0
for x in fo.read().split("\n"):
if x=='---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------':
start = 1
cntr += 1
continue
with open (str(cntr)+'.txt','a+') as opf:
if not start:
x = '\n'+x
opf.write(x)
start = 0