changeset 14:59b9339c2ed6 draft

Uploaded
author greg
date Tue, 27 Nov 2018 10:49:09 -0500
parents e33fdb18762f
children 13de3d5839ac
files validate_temperature_data.py
diffstat 1 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/validate_temperature_data.py	Tue Nov 27 10:43:58 2018 -0500
+++ b/validate_temperature_data.py	Tue Nov 27 10:49:09 2018 -0500
@@ -128,6 +128,11 @@
             accumulated_msgs = validate_decimal(i, tmax, accumulated_msgs, "tmax")
         else:
             if i == 0:
+                try:
+                    last_doy = int(doy)
+                except Exception:
+                    accumulated_msgs = add_error_msg(accumulated_msgs, "Line %d contains an invalid DOY (%s must be an integer)." % (i, doy))
+                    stop_error(accumulated_msgs)
                 if line != ACTUALS_HEADER:
                     accumulated_msgs = add_error_msg(accumulated_msgs, "The header is invalid, must be %s" % ACTUALS_HEADER)
                 continue
@@ -146,17 +151,14 @@
             doy = items[3].strip()
             accumulated_msgs = validate_integer(i, doy, accumulated_msgs, "doy")
             # Make sure the DOY values are consecutive.
-            if i==0:
-                last_doy = int(doy)
-            else:
-                try:
-                    if int(doy) != (last_doy + 1):
-                        accumulated_msgs = add_error_msg(accumulated_msgs, "Line %d contains a DOY (%s) that is not conexcutive." % (i, doy))
-                        stop_error(accumulated_msgs)
-                except Exception:
-                    # The error for an invalid integer was captured above.
-                    pass
-                last_doy += 1
+            try:
+                if int(doy) != (last_doy + 1):
+                    accumulated_msgs = add_error_msg(accumulated_msgs, "Line %d contains a DOY (%s) that is not conexcutive." % (i, doy))
+                    stop_error(accumulated_msgs)
+            except Exception:
+                # The error for an invalid integer was captured above.
+                pass
+            last_doy += 1
             tmin = items[4].strip()
             accumulated_msgs = validate_decimal(i, tmin, accumulated_msgs, "tmin")
             tmax = items[5].strip()