def __init__(self, structure, variables, csv_data): self.structure = structure self.csv_data = csv_data self.notices = [] # lookup of all variables in this table self.variables = dict([(v, variable.get(v)) for v in variables]) # global variables are common to all cells global_variables = [k for k, v in structure['global']][::-1] self.statistic_id = global_variables.pop() self.global_variables = global_variables[::-1] # columns variables are partially indented self.indented_columns = {} for var, level in structure['top']: self.indented_columns[level] = self.indented_columns.get(level, []) + [var] # row variables are common to each cell in a row self.num_row_variables = None self.row_variables = [k for k, v in structure['pre']] self.row_id = 0 # column headers combine general information that is true for all # columns self.column_headers = [] self.column_headers_parsed = False self.column_data = {} self.column_types = None self.column_units = None # the actual results self.cells = [] self.current_row_data = None
def __init__(self, structure, variables, csv_data): self.structure = structure self.csv_data = csv_data self.notices = [] # lookup of all variables in this table self.variables = dict([(v, variable.get(v)) for v in variables]) # global variables are common to all cells global_variables = [k for k, v in structure['global']][::-1] self.statistic_id = global_variables.pop() self.global_variables = global_variables[::-1] # columns variables are partially indented self.indented_columns = {} for var, level in structure['top']: self.indented_columns[level] = self.indented_columns.get( level, []) + [var] # row variables are common to each cell in a row self.num_row_variables = None self.row_variables = [k for k, v in structure['pre']] self.row_id = 0 # column headers combine general information that is true for all # columns self.column_headers = [] self.column_headers_parsed = False self.column_data = {} self.column_types = None self.column_units = None # the actual results self.cells = [] self.current_row_data = None
def test_types(self): types = set() types_ausp = {} for variable in self.db.variables.find(): #print variable #assert False typ = variable.get('typ') types.add(typ) #types_ausp[typ] = types_ausp.get(typ, []) + [variable.get('auspraegungen')] print types
#run_once() print "TIME: %s" % (time.time() - begin) def run_once(): import terms terms.load_terms() if __name__ == "__main__": logging.basicConfig(level=logging.INFO) #logging.getLogger('suds').setLevel(logging.ERROR) if sys.argv[1] == 'variables': import variable variable.all() elif sys.argv[1] == 'variable': import variable pprint(variable.get(sys.argv[2])) elif sys.argv[1] == 'table': import table pprint(table.get(sys.argv[2])) elif sys.argv[1] == 'statistic': import statistic pprint(statistic.get(sys.argv[2])) elif sys.argv[1] == 'load': import statistic statistic.all() elif sys.argv[1] == 'test': test_load()
#logging.info(table.get('12211-0104', force_reload=True)) #run_once() print "TIME: %s" % (time.time() - begin) def run_once(): import terms terms.load_terms() if __name__ == "__main__": logging.basicConfig(level=logging.INFO) #logging.getLogger('suds').setLevel(logging.ERROR) if sys.argv[1] == 'variables': import variable variable.all() elif sys.argv[1] == 'variable': import variable pprint(variable.get(sys.argv[2])) elif sys.argv[1] == 'table': import table pprint(table.get(sys.argv[2])) elif sys.argv[1] == 'statistic': import statistic pprint(statistic.get(sys.argv[2])) elif sys.argv[1] == 'load': import statistic statistic.all() elif sys.argv[1] == 'test': test_load()