Guest User

Untitled

a guest
Feb 22nd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import fileinput
  3.  
  4. lines = (line.split('\x1e') for line in fileinput.input())
  5. data = []
  6. for line in lines:
  7. record = {}
  8. for part in line:
  9. key, *value = map(str.strip, part.split('\x1f'))
  10. if key:
  11. record[key] = [(x[0], x[1:]) for x in value if x]
  12. data.append(record)
  13. print(data)
Add Comment
Please, Sign In to add comment