Example #1
0
   def extract(self,key):
      """Extract a line of data specified by 'key' as a list.

      Warning: This method is provided only for expediency, it will not work correctly unless the desired line is the only one containing exactly the string given.
      """
      datafile = open(self.directory+self.name, 'rb')
      keylen = len(key)
      for line in datafile:
         if line.find(key)!=-1:
            r = [tryfloat(s) for s in line.split('#',1)[0].split()]
            if len(r) == 1: return r[0]
            return r
      return None
Example #2
0
 def extractall(self):
    return [[tryfloat(s) for s in l] for l in self.strextractall()]