10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-30 16:15:50 +01:00
QUESTDB_website/tools/lib/formats/default/lineHandler.py

33 lines
1.2 KiB
Python
Raw Normal View History

2020-07-03 14:51:12 +02:00
from ..formatHandlerBase import formatHandlerBase
from ..formatName import formatName
from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector
from ...utils import getValFromCell
2020-08-02 16:30:20 +02:00
import numpy as np
2020-07-03 14:51:12 +02:00
@formatName("line")
class lineHandler(formatHandlerBase):
def readFromTable(self,table):
datalist=list()
for col in range(1,np.size(table,1)):
col=table[:,col]
mymolecule=str(col[0])
mymethod=method(str(col[2]),str(col[1]))
initialState=self.TexOps.initialStates[mymolecule]
2020-10-08 18:41:13 +02:00
finsts=dataFileBase.convertState(table[3:,0],initialState,default=self.TexOps.defaultType,commands=self.Commands)
2020-07-03 14:51:12 +02:00
datacls=dict()
for index,cell in enumerate(col[3:]):
if str(cell)!="":
val,unsafe=getValFromCell(cell)
finst=finsts[index]
dt=finst[1]
if dt in datacls:
data=datacls[dt]
else:
cl=datafileSelector(dt)
data=cl()
datacls[dt]=data
data.molecule=mymolecule
data.method=mymethod
data.excitations.append(excitationValue(initialState,finst[0],val,type=finst[2],isUnsafe=unsafe))
for value in datacls.values():
datalist.append(value)
return datalist