Mercurial > repos > greg > validate_temperature_data
comparison validate_temperature_data.py @ 3:3de939253e55 draft
Uploaded
author | greg |
---|---|
date | Tue, 27 Nov 2018 09:53:52 -0500 |
parents | 57c418290b61 |
children | 9ca3ff390666 |
comparison
equal
deleted
inserted
replaced
2:57c418290b61 | 3:3de939253e55 |
---|---|
50 return add_error_msg(accumulated_msgs, "Line %d contains an incorrect %s integer value (%s)." % (line_no, label, decimal_string)) | 50 return add_error_msg(accumulated_msgs, "Line %d contains an incorrect %s integer value (%s)." % (line_no, label, decimal_string)) |
51 | 51 |
52 | 52 |
53 def validate_mmdd(line_no, mmdd, accumulated_msgs): | 53 def validate_mmdd(line_no, mmdd, accumulated_msgs): |
54 try: | 54 try: |
55 datetime.datetime.strptime(date_string, '%m-%d') | 55 datetime.datetime.strptime(mmdd, '%m-%d') |
56 return accumulated_msgs | 56 return accumulated_msgs |
57 except ValueError: | 57 except ValueError: |
58 return add_error_msg(accumulated_msgs, "Line %d contains an incorrect date format (%s must be mm-dd)." % (line_no, date_string)) | 58 return add_error_msg(accumulated_msgs, "Line %d contains an incorrect date format (%s must be mm-dd)." % (line_no, mmdd)) |
59 | 59 |
60 | 60 |
61 accumulated_msgs = "" | 61 accumulated_msgs = "" |
62 # Parse the input file, skipping the header, and validating | 62 # Parse the input file, skipping the header, and validating |
63 # that each data line consists of 31 comma-separated items. | 63 # that each data line consists of 31 comma-separated items. |