Python – dictionary to CSV

Dictionary to a CSV file is probably a good question, if you are hiring a VBA developer. For a python person it should be a trivial one, as this one should not be even a tough search in Google. Anyway, there could be a few hints, that could be needed.

Theatre of Sofia on this random picture from my phone. Nothing to do with dictionaries, nor CSV files.

Anyway, it could happen, that if you do not explicitly specify the newline named parameter in writing the csv file, you will get an empty line. And you have to debug and search again. That’s why I am putting the whole code here:

The result looks as fancy as the one below. As you see, because the second item in fields is “year”, it is listed second in the csv. Small tricks, but interesting:

That’s all!

Tagged with: , ,