Commit 605ce88b authored by Jean-Francois Dockes's avatar Jean-Francois Dockes
Browse files

Python3: get csv export to work with python2 and python3

parent e8734ec9
......@@ -367,14 +367,20 @@ def get_csv():
bottle.response.headers['Content-Type'] = 'text/csv'
bottle.response.headers['Content-Disposition'] = 'attachment; filename=recoll-%s.csv' % normalise_filename(qs)
res, nres, timer = recoll_search(query, False)
si = io.StringIO()
if py3k:
si = io.StringIO()
else:
si = io.BytesIO()
cw = csv.writer(si)
fields = config['csvfields'].split()
cw.writerow(fields)
for doc in res:
row = []
for f in fields:
row.append(doc[f])
if f in doc:
row.append(doc[f].decode('utf-8'))
else:
row.append('')
cw.writerow(row)
return si.getvalue().strip("\r\n")
#}}}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment