csv encoding

main
Bob Mottram 2021-07-28 11:04:47 +01:00
parent ef606161a1
commit 35a1a3ecc9
2 changed files with 3 additions and 4 deletions

View File

@ -10800,8 +10800,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.httpPrefix,
self.server.domainFull,
self.path)
msg = json.dumps(catalogStr,
ensure_ascii=False).encode('utf-8')
msg = msg.encode('utf-8')
msglen = len(msg)
self._set_headers('text/csv',
msglen, None, callingDomain)

View File

@ -963,7 +963,7 @@ def sharesCatalogCSVEndpoint(baseDir: str, httpPrefix: str,
return ''
csvStr = \
'id,type,hasType,startDate,expiryDate,' + \
'quantity,price,currency,Image,description,\r\n'
'quantity,price,currency,Image,description,\n'
for item in catalogJson['DFC:supplies']:
csvStr += '"' + item['@id'] + '",'
csvStr += '"' + item['@type'] + '",'
@ -975,7 +975,7 @@ def sharesCatalogCSVEndpoint(baseDir: str, httpPrefix: str,
csvStr += '"' + item['DFC:price'].split(' ')[1] + '",'
csvStr += '"' + item['DFC:Image'] + '",'
description = item['DFC:description'].replace('"', "'")
csvStr += '"' + description + '",\r\n'
csvStr += '"' + description + '",\n'
return csvStr