Mercurial > repos > greg > validate_temperature_data
changeset 9:9f4f850c472d draft
Uploaded
author | greg |
---|---|
date | Tue, 27 Nov 2018 10:14:40 -0500 |
parents | 119c30a504db |
children | 1ce61b5b58d5 |
files | validate_temperature_data.py |
diffstat | 1 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/validate_temperature_data.py Tue Nov 27 10:10:30 2018 -0500 +++ b/validate_temperature_data.py Tue Nov 27 10:14:40 2018 -0500 @@ -73,22 +73,20 @@ # that each data line consists of 31 comma-separated items. if args.data_type == "normals": input_file = args.input_normals - header = NORMALS_HEADER last_doy = 0 num_normals_rows = 0 else: input_file = args.input_actuals - header = ACTUALS_HEADER with open(input_file, "r") as ih: for i, line in enumerate(ih): line = line.rstrip("\r\n") - if i == 0: - if line != header: - accumulated_msgs = add_error_msg(accumulated_msgs, "The header is invalid, must be %s" % header) - continue items = line.split(",") if args.data_type == "normals": num_normals_rows += 1 + if i == 0: + if line != NORMALS_HEADER: + accumulated_msgs = add_error_msg(accumulated_msgs, "The header is invalid, must be %s" % NORMALS_HEADER) + continue if i > 367: accumulated_msgs = add_error_msg(accumulated_msgs, "The input file contains more than 367 lines (must be 1 header line and 366 data lines).") stop_error(accumulated_msgs) @@ -129,6 +127,10 @@ tmax = items[9].strip() accumulated_msgs = validate_decimal(i, tmax, accumulated_msgs, "tmax") else: + if i == 0: + if line != ACTUALS_HEADER: + accumulated_msgs = add_error_msg(accumulated_msgs, "The header is invalid, must be %s" % ACTUALS_HEADER) + continue if i > 367: accumulated_msgs = add_error_msg(accumulated_msgs, "The input file contains more than 367 lines (must be 1 header line and no more than 366 data lines).") stop_error(accumulated_msgs)