def output(self, format="json"): csv_reader = UnicodeReader(open(self.input_csv, "rb")) if format == "csv": csv_writer = UnicodeWriter(open(self.output_csv, "wb")) schema_reader = open(self.output_schema, "rb") schema = [] config = Configuration() json_output = [] tmp = schema_reader.readlines() for header in tmp: header = header.strip() if header: schema.append(header) for line in csv_reader: # Cleaning is missing if line: row = [] data = config.format(tuple(line)) config.normalize(data) config.translate(data) if format == 'json': json_output.append(data) elif format == 'csv': for header in schema: row.append(data[header]) csv_writer.writerow(row) if format == 'json': print simplejson.dumps(data)
def get_name(self): mformat = Configuration().read(self.layer_type.name, "name_format") mvalues = [self.__attributes[x.strip()] for x in Configuration().read(self.layer_type.name, "name_columns")] return mformat.format(*mvalues)