Created
August 24, 2014 21:36
-
-
Save Echocage/5ac343fca95b07aa4a25 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = r"""File Name : File1.txt | |
Directory : Path\to\File1.txt | |
Created : 2012:04:15 10:15:32 | |
Accessed : 2012:04:18 13:28:18""" | |
items = [] | |
for line in data.split('\n'): | |
type = line.split(':')[0].strip() | |
rest = ':'.join(map(lambda x: x.strip(), line.split(':')[1:])) | |
if type == 'File Name': | |
items.append({type: rest}) | |
else: | |
items[-1][type] = rest | |
print ','.join(items[0].iterkeys()) | |
for dictionary in items: | |
print ','.join(dictionary.itervalues()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment