def to_csv(self, data, options=None):
        """
        Given some Python data, produces JSON output.
        """
        response = HttpResponse()
        options = options or {}
        data = self.to_simple(data, options)
        writer = csv.writer(response)

        writer.writerow(data['objects'][0].keys())
        for item in data['objects']:
            writer.writerow(
                [unicode(item[key]).encode('utf-8', 'replace')
                 for key
                 in item.keys()]
            )
dataset/ETHPy150Open california-civic-data-coalition/django-calaccess-campaign-browser/calaccess_campaign_browser/utils/serializer.py/CIRCustomSerializer.to_csv/original