Skip to content

Instantly share code, notes, and snippets.

@philippbayer
Created April 17, 2012 23:53
Show Gist options
  • Save philippbayer/2409977 to your computer and use it in GitHub Desktop.
Save philippbayer/2409977 to your computer and use it in GitHub Desktop.
Python dictionary with defaultdict
from collections import defaultdict
d = defaultdict(list)
for line in file_handle:
line_list = line.split
d[line_list[0]].append(line_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment