diff options
author | BonfaceKilz | 2020-10-09 03:04:30 +0300 |
---|---|---|
committer | BonfaceKilz | 2020-10-09 03:06:19 +0300 |
commit | 16cd94dfa0e892576f1c566948b775b954f7f508 (patch) | |
tree | 539fa8e80ec25c4b5299ec585349668b4e8a4fdb /wqflask | |
parent | 4e786c530d231718773cb629d3cac7449314c151 (diff) | |
download | genenetwork2-16cd94dfa0e892576f1c566948b775b954f7f508.tar.gz |
Fix export function on traits and analysis page
* wqflask/wqflask/views.py (export_trait_excel): Write data as bytes
instead of strings. See:
https://stackoverflow.com/questions/32075135/python-3-in-memory-zipfile-error-string-argument-expected-got-bytes
* wqflask/wqflask/show_trait/export_trait_data.py: Convert cmp
function into a key function.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/show_trait/export_trait_data.py | 4 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/wqflask/wqflask/show_trait/export_trait_data.py b/wqflask/wqflask/show_trait/export_trait_data.py index 2d76b935..f2132966 100644 --- a/wqflask/wqflask/show_trait/export_trait_data.py +++ b/wqflask/wqflask/show_trait/export_trait_data.py @@ -1,7 +1,7 @@ import simplejson as json from pprint import pformat as pf - +from functools import cmp_to_key from base.trait import create_trait from base import data_set @@ -46,7 +46,7 @@ def get_export_metadata(trait_id, dataset_name): def dict_to_sorted_list(dictionary): sorted_list = [item for item in list(dictionary.items())] - sorted_list = sorted(sorted_list, cmp=cmp_samples) + sorted_list = sorted(sorted_list, key=cmp_to_key(cmp_samples)) sorted_values = [item[1] for item in sorted_list] return sorted_values diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index e8d17613..c37be418 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -376,7 +376,7 @@ def export_trait_excel(): logger.info("sample_data - type: %s -- size: %s" % (type(sample_data), len(sample_data))) - buff = io.StringIO() + buff = io.BytesIO() workbook = xlsxwriter.Workbook(buff, {'in_memory': True}) worksheet = workbook.add_worksheet() for i, row in enumerate(sample_data): |