def make_csv_writer(self):
vinfo = sys.version_info
- if vinfo.major >= 3 and vinfo.minor >= 12:
- quoting = csv.QUOTE_STRINGS
+ if self.uf.download_fmt == CSV:
+ if vinfo.major >= 3 and vinfo.minor >= 12:
+ quoting = csv.QUOTE_STRINGS
+ else:
+ quoting = csv.QUOTE_NONNUMERIC
+ return csv.writer(self.tfile, quoting=quoting)
else:
- quoting = csv.QUOTE_NONNUMERIC
- return csv.writer(self.tfile, quoting=quoting)
+ return csv.writer(self.tfile, dialect=csv.excel_tab)
def make_download(self, cur):
# Optimized to minimize RAM usage
pmd_response.content_type = 'text/csv'
else:
pmd_response.content_type = 'text/plain'
+ if uh.uf['download_fmt'] == CSV:
+ suffix = 'csv'
+ else:
+ suffix = 'txt' # Tab delimited
pmd_response.content_disposition = \
- f'attachment; filename={response["dl_filename"]}.csv'
+ f'attachment; filename={response["dl_filename"]}.{suffix}'
pmd_response.app_iter = codecs.iterencode(uh.tfile, 'utf_8')