Jul-15-2019, 08:38 PM
I would have something along these lines:
rows = [] mode = 'nowhere' for line in file: if line: if mode == 'nowhere': mode = 'header' header_data = [] # resets the header info for each new section elif 'Access' in line: if 'No users with' in line: continue mode == 'access' if mode == 'header': # pull out header information and put it into header_data elif mode == 'Access': access_type, users = line.split(':') # everything after the colon for user in users.split(','): rows.append(header_data + [user.strip(), access_type.strip()]) else: mode = 'nowhere' # start looking for new sectionThe idea is to figure out what you need to do based on what the line looks like and perhaps what the previous line is.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures