Assuming your values are lists/tuples you can do the following and that you are using OrderedDict
dictionary = {'key1': ['value1', 'value2', 'value3'], 'key2': ['value1', 'value2']}
for key, values in dictionary.items():
for value in values:
print '{} {}'.format(key, value)
If you are using a normal dict (i.e. not an OrderedDict
) then you need to sort first:
dictionary = {'key1': ['value1', 'value2', 'value3'], 'key2': ['value1', 'value2']}
for key, values in sorted(dictionary.items()):
for value in values:
print '{} {}'.format(key, value)
The code above only prints the values as you had in your example output. You can write them to a csv file or do whatever you desire.
The output for the second example would be:
key1 value1
key1 value2
key1 value3
key2 value1
key2 value2