 James Talbot  1
Bohemians   Derek Pender  2
Bohemians   Darragh Leahy 3
Cork City   Mark McNulty  1
Cork City   Colm Horgan   2
Cork City   Alan Bennett  3
Derry City  Peter Cherrie  1
Derry City  Conor McDermott  2
Derry City  Ciaran Coll  3

I know I need to first (1) Divide the file into sections based on team, and then (2) within each team section; combine each name + number field into pairs to assign each number to a name.
I wrote this little bit of code to parse the big file into each sports team:
import sys
fileopen = open(sys.argv[1])
recording = False
for line in fileopen:
    if not recording:
        if line.startswith('PREMI'):
            recording = True
    elif line.startswith('2019 SEA'):
            recording = False
    else:   
        print(line)

But I'm stuck, because the above code won't divide up the block of text per team (i.e. i need multiple blocks of text extracted to separate strings or lists?). Can someone advise how to divide up the text file I have per team (so in this example, I should be left with three blocks of text...and then somehow I can work on each team-divided block of text to pair numbers and names).

A:

Soooo, not necessarily true to form and I don't take into consideration the other libraries you'd used, but it was designed to give you a start. You can reformat it however you wish.
>>> string = '''2019 SEASON 

PREMIER DIVISION SQUAD NUMBERS 
CLUB: BOHEMIANS

1

James Talbot

GK

2

Derek Pender 

DF

3

Darragh Leahy 

DF

.... some more names....

2019 SEASON 

PREMIER DIVISION SQUAD NUMBERS 
CLUB: CORK CITY 

1

Mark McNulty

GK

2

Colm Horgan

DF

3

Alan Bennett

DF
....some more names....

2019 SEASON 

PREMIER DIVISION SQUAD NUMBERS 
CLUB: DERRY CITY

1

Peter Cherrie

GK

2

Conor McDermott

DF

3

Ciaran Coll

DF'''

>>> def reorder(string):
        import re
        headers = ['Team', 'Name', 'Number']
        print('\n')
        print(headers)
        print()
        paragraphs = re.findall('2019[\S\s]+?(?=2019|$)', string)
        for paragraph in parag