I have a little dashboard at work which generates keys and amounts of certain calculation groups. The user can also choose to export to a CSV file.
However, it is breaking because one calculation group has keys which have commas in them. So I need to make it semicolon deliminated, and hopefully in a way that opens nicely.
This is my code currently:
from flask import Flask, render_template, request, make_response, Response
if 'export' in request.form.getlist('export'):
out = []
for k,v in result.items():
out.append(k + ';' + str(v) + '\n')
csv = ''.join(out)
response = make_response(csv)
cd = 'attachment; filename = LCRdrillback.csv'
response.headers['Content-Disposition'] = cd
response.mimetime='text/csv'
return response
The semi colon in that code block used to be a comma. How do I need to tweak this to make it semicolon friendly? So that opens with the keys and values in different columns?
I am using flask as well.