Iteratively read data from a GTFS table. Returns namedtuples.

def iterread(self, table):
    """Iteratively read data from a GTFS table. Returns namedtuples."""
    self.log('Reading: %s'%table)
    # Entity class
    cls = self.FACTORIES[table]
    f = self._open(table)
    # csv reader
    if unicodecsv:
      data = unicodecsv.reader(f, encoding='utf-8-sig')
    else:
      data = csv.reader(f)
    header = data.next()
    headerlen = len(header)
    ent = collections.namedtuple(
      'EntityNamedTuple',
      map(str, header)
    )
    for row in data:
      if len(row) == 0:
        continue
      # Get rid of extra spaces.
      row = [i.strip() for i in row]
      # pad to length if necessary... :(
      if len(row) < headerlen:
        row += ['']*(headerlen-len(row))
      yield cls.from_row(ent._make(row), self)
    f.close()