def _load_variables(self):
     self._variables = []
     for vn in self._ds.variables.keys():
         var = self._ds.variables[vn]
         newvar = Variable()
         newvar.index_key = vn
         newvar.name = vn
         newvar.attributes = []
         for ak in var.ncattrs():
             att = var.getncattr(ak)
             if ak == "units":
                 newvar.units = att
             attr = Attribute()
             attr.name = ak
             attr.value = att
             newvar.attributes.append(attr)
         self._variables.append(newvar)
 def _load_variables(self):
     self._variables = []
     for vn in self._ds.variables.keys():
         var = self._ds.variables[vn]
         newvar = Variable()
         newvar.index_key = vn
         newvar.name = vn
         newvar.attributes = []
         for ak in var.ncattrs():
             att = var.getncattr(ak)
             if ak == 'units':
                 newvar.units = att
             attr = Attribute()
             attr.name = ak
             attr.value = att
             newvar.attributes.append(attr)
         self._variables.append(newvar)
    def _parse_attribute(self, line="", correct_table_type=False, variables=None, attributes=None):
        # strip out leading %
        new_line = line.replace("%", "")

        parsed_line = new_line.partition(":")
        if parsed_line[0] == "TableColumnTypes" and correct_table_type:
            cols = parsed_line[2].split(" ")
            index = 0
            for col in cols:
                if not col == "" and not col == "\n":
                    var = Variable()
                    var.attributes = []
                    var.name = col
                    var.index_key = str(index)
                    self._variables.append(var)
                    index += 1
        elif not parsed_line[0].startswith("Table"):
            if not parsed_line[2] == "":
                att = Attribute()
                att.name = parsed_line[0]
                att.value = parsed_line[2].replace("\n", "")
                attributes.append(att)
    def _parse_attribute(self, line='', correct_table_type=False, variables=None, attributes=None):
        #strip out leading %
        new_line = line.replace('%', '')

        parsed_line = new_line.partition(':')
        if parsed_line[0] == 'TableColumnTypes' and correct_table_type:
            cols = parsed_line[2].split(' ')
            index = 0
            for col in cols:
                if not col == '' and not col == '\n':
                    var = Variable()
                    var.attributes = []
                    var.name = col
                    var.index_key = str(index)
                    self._variables.append(var)
                    index += 1
        elif not parsed_line[0].startswith('Table'):
            if not parsed_line[2] == '':
                att = Attribute()
                att.name = parsed_line[0]
                att.value = parsed_line[2].replace('\n', '')
                attributes.append(att)
Пример #5
0
    def _parse_attribute(self, line='', correct_table_type=False, variables=None, attributes=None):
        #strip out leading %
        new_line = line.replace('%', '')

        parsed_line = new_line.partition(':')
        if parsed_line[0] == 'TableColumnTypes' and correct_table_type:
            cols = parsed_line[2].split(' ')
            index = 0
            for col in cols:
                if not col == '' and not col == '\n':
                    var = Variable()
                    var.attributes = []
                    var.name = col
                    var.index_key = str(index)
                    self._variables.append(var)
                    index += 1
        elif not parsed_line[0].startswith('Table'):
            if not parsed_line[2] == '':
                att = Attribute()
                att.name = parsed_line[0]
                att.value = parsed_line[2].replace('\n', '')
                attributes.append(att)