added method to set data value in given column (by name)

This commit is contained in:
Philip Eisenlohr 2012-02-15 14:50:51 +00:00
parent bd32f1bf1a
commit d642730776
1 changed files with 18 additions and 0 deletions

View File

@ -126,6 +126,24 @@ class ASCIItable():
for item in what: self.data_append(item)
else: self.data += [str(what)]
# ------------------------------------------------------------------
def data_set(self,
what,where):
idx = -1
try:
idx = self.labels.index(where)
if len(self.data) <= idx:
self.data_append(['n/a' for i in xrange(idx+1-len(self.data))]) # grow data if too short
self.data[idx] = str(what)
except ValueError:
pass
return idx
# ------------------------------------------------------------------
def data_clear(self):
self.data = []
# ------------------------------------------------------------------
def data_asFloat(self):
return map(self._transliterateToFloat,self.data)