diff options
Diffstat (limited to 'wqflask')
-rwxr-xr-x | wqflask/wqflask/show_trait/export_trait_data.py | 17 | ||||
-rwxr-xr-x | wqflask/wqflask/views.py | 6 |
2 files changed, 19 insertions, 4 deletions
diff --git a/wqflask/wqflask/show_trait/export_trait_data.py b/wqflask/wqflask/show_trait/export_trait_data.py index f7f2d6d4..f5d02e73 100755 --- a/wqflask/wqflask/show_trait/export_trait_data.py +++ b/wqflask/wqflask/show_trait/export_trait_data.py @@ -21,6 +21,19 @@ def export_sample_table(targs): def dict_to_sorted_list(dictionary): sorted_list = [item for item in dictionary.iteritems()] - sorted_list = sorted(sorted_list, key=operator.itemgetter(0)) + sorted_list = sorted(sorted_list, cmp=cmp_samples) sorted_values = [item[1] for item in sorted_list] - return sorted_values
\ No newline at end of file + return sorted_values + +def cmp_samples(a, b): + if b[0] == 'name': + return 1 + elif b[0] == 'value': + if a[0] == 'se': + return 1 + else: + return -1 + elif b[0] == 'se': + return -1 + else: + return 0
\ No newline at end of file diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 89b7ba43..b42e0d4c 100755 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -236,13 +236,15 @@ def export_trait_excel(): for i, row in enumerate(sample_data): worksheet.write(i, 0, row[0]) worksheet.write(i, 1, row[1]) + if len(row) > 2: + worksheet.write(i, 2, row[2]) workbook.close() excel_data = buff.getvalue() buff.close() return Response(excel_data, mimetype='application/vnd.ms-excel', - headers={"Content-Disposition":"attachment;filename=test.xlsx"}) + headers={"Content-Disposition":"attachment;filename=sample_data.xlsx"}) @app.route('/export_trait_csv', methods=('POST',)) def export_trait_csv(): @@ -262,7 +264,7 @@ def export_trait_csv(): return Response(csv_data, mimetype='text/csv', - headers={"Content-Disposition":"attachment;filename=test.csv"}) + headers={"Content-Disposition":"attachment;filename=sample_data.csv"}) @app.route("/show_trait") def show_trait_page(): |