From d07a3b4a6d4a31f10db99ef4f3ad0ff8daca5eec Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Fri, 22 Feb 2019 15:10:11 +1100 Subject: [PATCH] Use raw strings for regular expressions --- waternsw_grabber/waternsw_grabber.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/waternsw_grabber/waternsw_grabber.py b/waternsw_grabber/waternsw_grabber.py index 086abe9..672bbd4 100644 --- a/waternsw_grabber/waternsw_grabber.py +++ b/waternsw_grabber/waternsw_grabber.py @@ -265,7 +265,7 @@ def extract_records(input_dir, output_dir, clean_up=False): for zip_name in tqdm(zip_names): # Skip duplicate downloads - if re.search('\([0-9]+\)', zip_name): + if re.search(r'\([0-9]+\)', zip_name): continue # Rename '.part' file if zip was not correctly downloaded @@ -285,11 +285,11 @@ def extract_records(input_dir, output_dir, clean_up=False): # Get bore specifics meta = df.iloc[1, -1] - lat = float(re.search('(?<=Lat:)\S+', meta).group()) - lon = float(re.search('(?<=Long:)\S+', meta).group()) - elev = float(re.search('(?<=Elev:).+(?=m)', meta).group()) - address = re.search('(?<=\d\.\d\.\d - ).+(?=\sLat)', meta).group() - bore_id = re.search('^\S+', meta).group() + lat = float(re.search(r'(?<=Lat:)\S+', meta).group()) + lon = float(re.search(r'(?<=Long:)\S+', meta).group()) + elev = float(re.search(r'(?<=Elev:).+(?=m)', meta).group()) + address = re.search(r'(?<=\d\.\d\.\d - ).+(?=\sLat)', meta).group() + bore_id = re.search(r'^\S+', meta).group() site, hole, pipe = bore_id.split('.') # FIXME: detect basin automatically