From dd749ca0d9c0a3e7134c08009651cde87d9b5dd1 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Fri, 1 Mar 2019 17:04:58 +1100 Subject: [PATCH] Set elevation to NaN if value is missing --- waternsw_grabber/waternsw_grabber.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/waternsw_grabber/waternsw_grabber.py b/waternsw_grabber/waternsw_grabber.py index 5102c06..8f73f2d 100644 --- a/waternsw_grabber/waternsw_grabber.py +++ b/waternsw_grabber/waternsw_grabber.py @@ -9,6 +9,7 @@ import shutil import logging import warnings import requests +import numpy as np import pandas as pd from tqdm import tqdm from selenium import webdriver @@ -299,7 +300,10 @@ def extract_definitions(input_dir, output_dir): site_data = meta['Sites:'][0] lat = float(re.search(r'(?<=Lat:)\S+', site_data).group()) lon = float(re.search(r'(?<=Long:)\S+', site_data).group()) - elev = float(re.search(r'(?<=Elev:).+(?=m)', site_data).group()) + try: + elev = float(re.search(r'(?<=Elev:).+(?=m)', site_data).group()) + except AttributeError: + elev = np.nan address = re.search(r'(?<=\d\.\d\.\d - ).+(?=\sLat)', site_data).group() bore_id = re.search(r'^\S+', site_data).group()