From 7b2654811b185a6a35492b143c49483c4a9d974a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Sun, 16 Feb 2020 15:22:21 +0100 Subject: [PATCH] getSubtableIndex is now a local function --- tools/lib/data.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/lib/data.py b/tools/lib/data.py index 543fbd80..89be4cec 100644 --- a/tools/lib/data.py +++ b/tools/lib/data.py @@ -65,6 +65,16 @@ class dataFileBase(object): @staticmethod def readFromTable(table,format=Format.LINE,default=dataType.ABS ,firstState=state(1,1,"A_1"),commands=[]): + def getSubtableIndex(table): + subtablesindex=list() + firstindex=2 + for i in range(3,np.size(table,0)): + if str(table[i,0])!="": + subtablesindex.append((firstindex,i-1)) + firstindex=i + subtablesindex.append((firstindex,np.size(table,0))) + return subtablesindex + datalist=list() switcher={ dataType.ABS:AbsDataFile, @@ -96,13 +106,7 @@ class dataFileBase(object): datalist.append(value) return datalist elif format==Format.COLUMN: - subtablesindex=list() - firstindex=2 - for i in range(3,np.size(table,0)): - if str(table[i,0])!="": - subtablesindex.append((firstindex,i-1)) - firstindex=i - subtablesindex.append((firstindex,np.size(table,0))) + subtablesindex=getSubtableIndex(table) for first, last in subtablesindex: for col in range(2,np.size(table,1)): datacls=dict() @@ -128,13 +132,7 @@ class dataFileBase(object): datalist.append(value) return datalist elif format==Format.TBE: - subtablesindex=list() - firstindex=2 - for i in range(3,np.size(table,0)): - if str(table[i,0])!="": - subtablesindex.append((firstindex,i-1)) - firstindex=i - subtablesindex.append((firstindex,np.size(table,0))) + subtablesindex=getSubtableIndex(table) for first, last in subtablesindex: datacls=dict() mymolecule=str(table[first,0])