Changes to skip ketone measurements; optionally skip manual readings; and support decimal figures in insulin and food doses.
This commit is contained in:
parent
b46b8b1eae
commit
5ec4b75d18
@ -79,6 +79,21 @@ def main():
|
||||
with open(args.input_file, 'r', newline='') as f:
|
||||
rows = from_csv(f)
|
||||
|
||||
''' Skip ketone entries '''
|
||||
rketones = re.compile('Ketone', flags=re.IGNORECASE);
|
||||
for row in rows:
|
||||
if rketones.search(row.get('measure_method')):
|
||||
rows.remove(row);
|
||||
elif rketones.search(row.get('comment')):
|
||||
rows.remove(row);
|
||||
|
||||
''' Skip finger stick test entries '''
|
||||
rfinger = re.compile('Blood', flags=re.IGNORECASE);
|
||||
if not args.fingerstick:
|
||||
for row in rows:
|
||||
if rfinger.search(row.get('comment')):
|
||||
rows.remove(row);
|
||||
|
||||
for row in rows:
|
||||
row = parse_entry(row, args.icons)
|
||||
|
||||
@ -531,6 +546,7 @@ def parse_entry(data, icons, fmt='%Y-%m-%d %H:%M:%S'):
|
||||
rrelevant = re.compile('(Food|Rapid-acting insulin|Long-acting insulin)(?: \((.*?)\))', flags=re.IGNORECASE)
|
||||
rduplicate = re.compile('^(I\$\^\{\d+\S?)(\}.*)$')
|
||||
commentparts = {}
|
||||
if data.get('comment') is not None:
|
||||
for part in data.get('comment').split('; '):
|
||||
relevant = rrelevant.search(part)
|
||||
if relevant is not None:
|
||||
@ -539,11 +555,10 @@ def parse_entry(data, icons, fmt='%Y-%m-%d %H:%M:%S'):
|
||||
|
||||
''' Convert floating point-style strings (2.0) to integer-style strings (2) '''
|
||||
try:
|
||||
if int(float(cvalue)) == float(cvalue):
|
||||
cvalue = int(float(cvalue))
|
||||
# if int(float(cvalue)) == float(cvalue)
|
||||
# cvalue = int(float(cvalue))
|
||||
# else
|
||||
# cvalue = float(cvalue)
|
||||
else:
|
||||
cvalue = float(cvalue)
|
||||
except:
|
||||
pass
|
||||
cvalue = str(cvalue)
|
||||
@ -788,6 +803,9 @@ def parse_arguments():
|
||||
parser.add_argument(
|
||||
'--icons', action='store_true', required=False, default=True,
|
||||
help=('Print food and injection indicators (default: true).'))
|
||||
parser.add_argument(
|
||||
'--fingerstick', action='store_true', required=False, default=True,
|
||||
help=('Include manual finger stick results (default: true).'))
|
||||
|
||||
parser.add_argument(
|
||||
'--units', action='store', required=False, type=str,
|
||||
|
Loading…
Reference in New Issue
Block a user