1.1.2.10. gnr.core.gnrlist - Operations on lists

Last page update: November 23, 2011

Classes:

External methods:

Complete reference:

1.1.2.10.2. XlsReader

there is no public method.

1.1.2.10.3. External methods

1.1.2.10.4. gnr.core.gnrlist - The complete reference list

Some useful operations on lists.

class gnr.core.gnrlist.GnrNamedList(index, values=None)

Row object. Allow access to data by column name. Allow also to add columns and alter data.

extractItems(columns)

It is a utility method of the sql fetch() method. It returns a list of namedlist (that is, a list of dictionaries).

Parameters:columns – the items of the namedlist dict
extractValues(columns)

It is a utility method of the sql fetch() method. It returns a list of namedlist (that is, a list of dictionaries).

Parameters:columns – the values of the namedlist dict
get(x, default=None)

Same of get method’s dict

Parameters:
  • x – TODO
  • default – the value returned if self[x] is None
has_key(x)

Same of has_key method’s dict. Return True if the key is in the dict, False otherwise

Parameters:x – the key to test
items()

Same of items method’s dict

iteritems()

Same of iteritems method’s dict

keys()

Same of keys method’s dict

pop(x, dflt=None)

Same of pop method’s dict

Parameters:
  • x – TODO
  • dflt – TODO
update(d)

Same of update method’s dict

Parameters:d – the dict to update
values()

Same of values method’s dict

class gnr.core.gnrlist.XlsReader(docname)

Read an XLS file

gnr.core.gnrlist.findByAttr(l, **kwargs)

Find elements in the l list having attributes with names and values as kwargs items. Return the list’s attributes

Parameters:l – the list
gnr.core.gnrlist.merge(*args)

TODO

gnr.core.gnrlist.readCSV(doc)

read a CSV file

Parameters:doc – the file to read
gnr.core.gnrlist.readCSV_new(doc)

This reads a CSV file - done by Jeff

Parameters:doc – the file to read
gnr.core.gnrlist.readTab(doc)

Read a “tab delimited” file.

The readCSV() method was misnamed (read not only CSV files) but must be left for legacy

Parameters:doc – the file to read
gnr.core.gnrlist.readXLS(doc)

Read an XLS file

Parameters:doc – the file to read
gnr.core.gnrlist.sortByAttr(l, *args)

TODO

Parameters:l – the list
gnr.core.gnrlist.sortByItem(l, *args, **kwargs)

Sort the list l, filled of objects with dict interface by items with key in *args. Return the list

Parameters:
  • l – the list
  • args – a list of keys to sort for. Each key can be reverse sorted by adding :d to the key.
  • hkeys – if True and a key contains ., then it is interpreted as a hierarchical path and sub dict are looked for