Exemple #1
0
 def write(self):
     try:
         self.csv_to_xlsx()
     except IOError as e:
         catalog = self.csv_dump_file.node or 'global'
         msg = f"Error escribiendo dump XLSX de dump {catalog} {self.csv_dump_file.file_name}: {e.__class__}: {e}"
         GenerateDumpTask.info(self.task, msg)
Exemple #2
0
    def generate(self):
        if not self.fields:
            GenerateDumpTask.info(self.task, f"No hay series cargadas para el catálogo {self.catalog}")
            return

        FullCsvGenerator(self.task, self.fields, self.catalog).generate()
        ValuesCsvGenerator(self.task, self.fields, self.catalog).generate()
        SourcesCsvGenerator(self.task, self.fields, self.catalog).generate()
        MetadataCsvGenerator(self.task, self.fields, self.catalog).generate()
    def write_distribution(self, distribution: Distribution,
                           writer: csv.writer):
        # noinspection PyBroadException
        try:
            df = read_distribution_csv(distribution)
            fields = distribution.field_set.all()
            fields = {field.title: field.identifier for field in fields}

            periodicity = meta_keys.get(distribution, meta_keys.PERIODICITY)
            df.apply(self.write_serie, args=(periodicity, fields, writer))
        except Exception as e:
            msg = f'[{self.tag} Error en la distribución {distribution.identifier}: {e.__class__}: {e}'
            GenerateDumpTask.info(self.task, msg)
            logger.error(msg)
 def write_distribution(self, distribution: Distribution,
                        writer: csv.writer):
     # noinspection PyBroadException
     try:
         fields = distribution.field_set.all()
         fields = {field.title: field.identifier for field in fields}
         periodicity = meta_keys.get(distribution, meta_keys.PERIODICITY)
         index_col = DistributionRepository(
             distribution).get_time_index_series().title
         df = DistributionCsvReader(distribution, index_col).read()
         df.apply(self.write_serie, args=(periodicity, fields, writer))
     except Exception as e:
         msg = f'[{self.tag} Error en la distribución {distribution.identifier}: {e.__class__}: {e}'
         GenerateDumpTask.info(self.task, msg)
         logger.warning(msg)