Store data in lists of dicts and use csv package

Output format is unchanged (except that csv.DictWriter insists on writing ints as 0.0 instead of 0)