Apr-21-2017, 09:08 PM
(This post was last modified: Apr-21-2017, 09:09 PM by ichabod801.)
You don't need to mess with regular expressions. Just chop them up and feed them in to a defaultdict, and you're good to go.
import collections data = collections.defaultdict(list) for file_data in ('AA08430022', 'AA08410234', 'AB81130138'): timestamp = file_data[:4] datum = file_data[4:] data[timestamp].append(datum)
Output:>>> data
{'AA08': ['430022', '410234'], 'AB81': ['130138']}
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