From 04431994b74a391039ba0d41ad95c2f361c246fa Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Mon, 16 Sep 2019 12:26:35 +1000 Subject: [PATCH] Fix parsing of parameter text --- port-authority-nsw/port_authority_nsw.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/port-authority-nsw/port_authority_nsw.py b/port-authority-nsw/port_authority_nsw.py index 4709a6d..6125dbb 100644 --- a/port-authority-nsw/port_authority_nsw.py +++ b/port-authority-nsw/port_authority_nsw.py @@ -80,11 +80,11 @@ meas = tree.get_element_by_id(f'MainContent_ctl{stn_id:02}_lblSummary') description = tree.get_element_by_id(f'MainContent_ctl{stn_id:02}_lblTitle') # Parse column names -text = re.split(':', meas.text) -parameters = text[::3] -entries = [re.split('(\D+)$', t) for t in text[1::3]] -values = [float(e[0]) for e in entries] -units = [e[1] for e in entries] +text = re.split(':\s|(m|s|knots|deg)\s', meas.text + ' ') +parts = [t for t in text if t] +parameters = [p.strip() for p in parts[::3]] +values = [float(p) for p in parts[1::3]] +units = parts[2::3] columns = [f'{p} ({u})' for p, u in zip(parameters, units)] # Parse time