From 94515b8b097a874a03bbe6262056782b5fa2b19a Mon Sep 17 00:00:00 2001 From: Kim Wall <30846798+kimble4@users.noreply.github.com> Date: Sun, 11 Dec 2022 21:22:40 +0000 Subject: [PATCH] More robust 'Name' field parsing Excel input If there is only a 'Name' field, and the contents aren't comma-separated, split on the last space in the name if there is one, or failing that, treat the entire thing as LastName. A minor convenience for working with Excel files that have come from somewhere other than CrossMgr. This also allows SeriesMgr to reliably read its own Excel output, where the names aren't always comma-separated. --- SeriesMgr/GetModelInfo.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/SeriesMgr/GetModelInfo.py b/SeriesMgr/GetModelInfo.py index fd4279564..c9928c67e 100644 --- a/SeriesMgr/GetModelInfo.py +++ b/SeriesMgr/GetModelInfo.py @@ -227,7 +227,12 @@ def ExtractRaceResultsExcel( raceInSeries ): try: info['lastName'], info['firstName'] = name.split(',',1) except: - pass + # Failing that, split on the last space character. + try: + info['firstName'], info['lastName'] = name.rsplit(' ',1) + except: + # If there are no spaces to split on, treat the entire name as lastName. This is fine. + info['lastName'] = name if not info['firstName'] and not info['lastName']: continue