Writing defaultdict to CSV file
csv is meant to store rows of data, not a simple dictionary. You can use json for that:

import json

# writing
json.dump(yourdict, open(filename, 'w'))

# reading
yourdict = json.load(open(filename))