with ZipFile(your_zip_file, 'w', ZIP_DEFLATED) as zip_file:
    string_buffer = StringIO()
csvwriter = csv.DictWriter(string_buffer, delimiter=',', fieldnames=fieldnames)
csvwrite.writeheader()
for row in cdrdata:
    csvwrite.writerow(row)
zip_file.writestr(filename + '.csv', string_buffer.getvalue())
How to compress csv file into zip archive directly?