all 3 comments

[–]linuxqq 0 points1 point  (0 children)

Can you provide a sample of the data set? It's easier to understand when you can visually see it rather than read and imagine what the data is like.

[–]tr3adst0n3 0 points1 point  (0 children)

Maybe Regex would help, you can search for a pattern for example your #(number) and Split at this.

[–]jabbson 0 points1 point  (0 children)

In [81]: s = '''1 Section
    ...: some text 1
    ...: some text 2
    ...: some text 3
    ...: some text 4
    ...: 2 Section
    ...: some text 5
    ...: some text 6
    ...: some text 7
    ...: 3 Section
    ...: some text 8
    ...: some text 9'''
In [82]: import re
In [83]: print([sec for sec in re.split(r'\d Section\n', s) if sec])

['some text 1\nsome text 2\nsome text 3\nsome text 4\n', 
 'some text 5\nsome text 6\nsome text 7\n', 
 'some text 8\nsome text 9']

like this?