def execute(self): store_inventory_rows, _ = CSVInputOutput().read_csv_file( self.store_inventory) bsq_rows, _ = CSVInputOutput().read_csv_file(self.bsq) store_priority_static_rows, _ = CSVInputOutput().read_csv_file( self.store_priority_static) self._write_product_list(bsq_rows, store_inventory_rows) self._write_store_list(store_priority_static_rows) self._write_warehouse_list(store_priority_static_rows)
def _write_warehouse_list(self, store_priority_static_rows): warehouse_list = self._gen_warehouse_list(store_priority_static_rows) header = [ BrandFilesConstants.STORE_CODE, BrandFilesConstants.WAREHOUSE_CODE ] CSVInputOutput().write_csv_to_file_dictwriter( self.output_warehouse_list, header, warehouse_list)
def handle(self, *args, **kwargs): brand = kwargs['brand'] model = kwargs['model'] csvfile = kwargs['csvfile'] brand_model = BrandModel.objects.get(name=brand) ImporterInterface(model_name=model, brand=brand_model, file=csvfile, reader=CSVInputOutput()).execute()
def upload_files(self, request, queryset): brand = 'Amazon' model = 'SalesTransaction' csvfile = 'input_data/Sales-1.csv' brand_model = BrandModel.objects.get(name=brand) from automatic_replenishment_system.retail_core.core.periodic.importer_interface import ImporterInterface from automatic_replenishment_system.retail_core.core.utils.csv_utils import CSVInputOutput ImporterInterface(model_name=model, brand=brand_model, file=csvfile, reader=CSVInputOutput()).execute()
def _write_to_file(self, csv_rows, file_name): if not csv_rows: return header = list(csv_rows[0].keys()) CSVInputOutput().write_csv_to_file_dictwriter(file_name, header, csv_rows)
def _write_product_list(self, bsq_rows, store_inventory_rows): product_list = self._gen_product_list(bsq_rows, store_inventory_rows) header = [BrandFilesConstants.PRODUCT_CODE] CSVInputOutput().write_csv_to_file_dictwriter(self.output_product_list, header, product_list)