From 06a75a3adbc877f2db7be45eacadc5d7eb9f2ca6 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Fri, 20 Jul 2018 10:30:39 +1000 Subject: [PATCH] Ensure survey dates are saved in correct order --- survey_tools.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/survey_tools.py b/survey_tools.py index c9eec31..b9e2548 100644 --- a/survey_tools.py +++ b/survey_tools.py @@ -143,7 +143,7 @@ def update_survey_output(df, output_dir): output_dir: directory where csv files are saved Returns: - None + True if current survey is latest, otherwise False """ # Merge current survey with existing data profiles = df['Profile'].unique() @@ -168,5 +168,10 @@ def update_survey_output(df, output_dir): except FileExistsError: pass + # Ensure survey dates are in correct order + elev_cols = sorted([col for col in master.columns if 'Elevation' in col]) + other_cols = [col for col in master.columns if 'Elevation' not in col] + master = master[other_cols + elev_cols] + # Export updated results master.to_csv(csv_name, index=False)