diff options
-rw-r--r-- | wqflask/wqflask/export_traits.py | 8 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/wqflask/wqflask/export_traits.py b/wqflask/wqflask/export_traits.py index a22d6acc..5459dc31 100644 --- a/wqflask/wqflask/export_traits.py +++ b/wqflask/wqflask/export_traits.py @@ -65,14 +65,18 @@ def export_search_results_csv(targs): traits_by_group = sort_traits_by_group(trait_list) file_list = [] - for group in list(traits_by_group.keys()): + for group in traits_by_group: group_traits = traits_by_group[group] + samplelist = group_traits[0].dataset.group.samplelist + if not samplelist: + continue + buff = io.StringIO() writer = csv.writer(buff) csv_rows = [] sample_headers = [] - for sample in group_traits[0].dataset.group.samplelist: + for sample in samplelist: sample_headers.append(sample) sample_headers.append(sample + "_SE") diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index ebe5303a..0714bd20 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -623,7 +623,7 @@ def export_traits_csv(): now = datetime.datetime.now() time_str = now.strftime('%H:%M_%d%B%Y') filename = "export_{}".format(time_str) - memory_file = io.StringIO() + memory_file = io.BytesIO() with ZipFile(memory_file, mode='w', compression=ZIP_DEFLATED) as zf: for the_file in file_list: zf.writestr(the_file[0], the_file[1]) |