Esempio n. 1
0
 def initializeDB(self):
      listAttr=self.wrapper.getAttrList(detail='all')
      headers=listAttr['Name'].tolist()
      listshot=h5.getNbrfromFile(h5.listFiles())
      listattrs=[]
      for shot in listshot:   
          print shot
          paths=self.wrapper.getPath(headers,shot)
          #print paths
          #print h5.listAttrs(shot,paths)
          attrs=h5.listAttrs(shot,paths)
          listattrs.append(attrs)
      df=pd.DataFrame(listattrs,index=listshot,columns=headers) 
      #print listAttr['Name']
      for x in listAttr.Name.values:
          attr=listAttr.Processing.values[listAttr.Name.values==x][0]
          if attr=='datetime':
              df[x]=pd.to_datetime(df[x])               
          if attr=='str':
              df[x]=df[x].astype('S32')
          if attr=='float':
              df[x]=df[x].astype(float)                 
          if attr=='bool':
              df[x]=df[x].astype(bool)         
      #df.convert_objects()
      df.to_hdf(self.store,'shotDB',format='table',nan_rep='nan',data_columns=True)
Esempio n. 2
0
    def addShot(self,shot):
        listAttr=self.wrapper.getAttrList(detail='all')
        headers=listAttr['Name'].tolist()
        
        paths=self.wrapper.getPath(headers,shot)
        attr=[h5.listAttrs(shot,paths)]
        df=pd.DataFrame(attr,index=[shot],columns=headers)

        for x in listAttr.Name.values:
             attr=listAttr.Processing.values[listAttr.Name.values==x][0]
             if attr=='datetime':
                 df[x]=pd.to_datetime(df[x])               
             if attr=='str':
                 df[x]=df[x].astype('S32')
             if attr=='float':
                 df[x]=df[x].astype(float)                 
             if attr=='bool':
                 df[x]=df[x].astype(bool)
        liste=pd.read_hdf(self.store,'shotDB')
        #df=df.drop(df.columns[[0]], axis=1)
       # liste=liste.drop(liste.columns[[0]], axis=1)
        #print liste
        liste=liste.append(df)
        liste.to_hdf(self.store,'shotDB',format='table',nan_rep='nan',data_columns=True,append=False)