rows = [['Austrialia', 'Mobile', '50'],
['Austrialia', 'Desktop', '50'],
['Brazil', 'Mobile', '23']]
report = {}
for country, category, value in rows:
if country not in report:
report[country] = {}
report[country][category] = value
report[country]['total'] = report[country].get('total', 0) + int(value)
for country in report:
# You will probably want to order and format this better.
print country + "," + ",".join([category+"="+str(report[country][category]) for category in report[country]])