So, I'm still a newbie with regex and python. I've been searching for some time but don't know how to ask what I'm looking for.
I need to get data from a formatted string into a list of lists, or dictionary.
-------------------------------------------------------------------
Frank 114 0 0 0 0 114
Joe 49 1 0 0 0 50
Bob 37 0 0 0 0 37
Sally 34 2 0 0 0 36
This is the output of a script. Currently I have:
match_list = []
match = re.search('\n(\w+)\s+(\d*)\s+(\d*)', output)
if match:
match_list.append([match.group(1),
match.group(2),
match.group(3)])
>>>print match_list
[['frank', '114', '0']]
This is perfect, except that I need to have match_list return:
[['frank', '114', '0'],
['Joe', '49', '1'],
['Bob', '37', '0'],
['Sally', '34', '2']]
My initial thought was to for loop, and check if the match.group(1) was already listed, and if so move to the next, but then I realized I didn't know how to do that. But there you have it. I am having a hard time figuring this out. Any help would be fantastic! :)
Oh also. The list size changes. Sometimes there may only be one user, other times there may be 20 users. So I can just set up a giant static regex. (that I know of...)