def DownloadCsvReport(self, report_job_id=-1, report_xml=''):
        """Download and return report data in CSV format.

    Report consists of two parts: table and totals. Table contains column
    names and rows of data. The outgoing CSV will contain only columns and
    data rows. The totals are not included, but can be easily calculated from
    the CSV data.

    Args:
      [optional]
      report_job_id: str ID of the report job.
      report_xml: str Report in XML format. Used for testing and debugging.

    Returns:
      str Report data if all data is in ASCII.
      unicode Report data if report contains non-ASCII characters.
      None If report failed.
    """
        # Get XML report data.
        if not report_xml and report_job_id > -1:
            report_xml = self.DownloadXmlReport(report_job_id)
        if report_xml is None:
            return None

        # Prepare XML for DOM construction.
        report_xml = report_xml.replace(
            '<?xml version="1.0" standalone="yes"?>', '')
        csv_rows = []
        try:
            # Construct DOM object.
            dom = minidom.parseString(report_xml)

            # Get data columns.
            columns = []
            column_dom = dom.getElementsByTagName('column')
            for column_item in column_dom:
                if column_item.hasAttributes():
                    columns.append(column_item.attributes.item(0).value)

            # Get data rows.
            rows = []
            row_dom = dom.getElementsByTagName('row')
            for row_item in row_dom:
                if row_item.hasAttributes():
                    attrs = row_item.attributes
                    row = {}
                    for index in range(attrs.length):
                        row[attrs.item(index).name] = attrs.item(index).value
                    rows.append(row)

            # Combine columns and rows into CSV format.
            csv_rows = [[column for column in columns]]
            for row in rows:
                csv_rows.append([row[column] for column in columns])
        except:
            msg = ('Unable to parse report\'s data. Please, file a bug at '
                   'http://code.google.com/p/google-api-adwords-python-lib/'
                   'issues/list.')
            raise Error(msg)

        buffer = cStringIO.StringIO()
        # A workaround for reports that include non-ASCII characters (i.e. ø).
        try:
            csv.writer(buffer).writerows(csv_rows)
        except (UnicodeEncodeError, Exception):
            unicode_csv_rows = []
            for row in csv_rows:
                unicode_csv_rows.append(','.join(
                    [Utils.CsvEscape(item) for item in row]))
            return unicode('\n'.join(unicode_csv_rows))
        return buffer.getvalue().rstrip()
        if data.find(weird_char) > -1:
            data = data.replace(weird_char, '')

    pattern = re.compile(item['re'])
    groups = pattern.findall(data)
    lines = []
    for group in groups:
        if item['csv'] in ('categories', ):
            group = [x for x in group if x != '']
            if len(group) == 1:
                category = ''.join(group)
                continue
            else:
                path = ''.join(group)
            lines.append('%s,%s' %
                         (Utils.CsvEscape(str(Utils.HtmlUnescape(category))),
                          Utils.CsvEscape(str(Utils.HtmlUnescape(path)))))
        elif item['csv'] in ('countries', 'currencies'):
            lines.append('%s,%s' %
                         (Utils.CsvEscape(str(Utils.HtmlUnescape(group[0]))),
                          Utils.CsvEscape(str(Utils.HtmlUnescape(group[1])))))
        elif item['csv'] in ('error_codes', ):
            pattern = re.compile('<.*?>')
            message = list(group)[1]
            message = pattern.sub('', message)
            lines.append('%s,%s' %
                         (Utils.CsvEscape(str(Utils.HtmlUnescape(group[0]))),
                          Utils.CsvEscape(str(Utils.HtmlUnescape(message)))))
        elif item['csv'] in ('languages', ):
            # Convert '-' into ''.
            new_group = []