Created
March 6, 2020 12:26
-
-
Save duchenpaul/0ef331ac8c52e0abadd4b235d22d2758 to your computer and use it in GitHub Desktop.
validate date in a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
with open('test.txt') as f: | |
date_list = f.read().split('\n') | |
date_list = [ x.replace('"', '').strip() for x in date_list if x] | |
for x in date_list: | |
try: | |
datetime.strptime(x, '%m/%d/%Y') | |
except Exception as e: | |
print(x) | |
else: | |
pass | |
finally: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment