def generateInputJson(self): try: #Generate Index Configuration File csvgen = CSVgenerator(self.file, _start_word_, keyField, fieldList) csvFile = _input_directory_ + "SSPlan.csv" indexInfoList = csvgen.generateIndexDict(self.file, _start_word_, keyField) csvgen.writeDictToCSV(csvFile, indexInfoList) self.logger.info("csv updated---" + csvFile) indexdict = indexInfoList # End Dynamic Generation Code inputJson = self.parseAndGenerateInputMap(indexdict) filename = _input_directory_ + "ericsson_" + _obj_name_ + ".json" with open(filename, 'w') as f1: json.dump(inputJson, f1, indent=4) self.logger.info("Json generated after parsing Input file ---" + str(inputJson)) except (FileNotFoundError): self.logger.error("Input file missing:-") logging.exception(FileNotFoundError) raise ApplicationError("Input file missing for object:- " + config.nokiaObjectName + " Add input files & retry") except (Exception): self.logger.error( "Error while parsing input dump, check for the correct format") raise return filename
def generateInputJson(self): try: #Generate CSV File csvgen= CSVgenerator(self.file,_start_word_,keyField,fieldList) csvFile=_input_directory_+"qos.csv" indexInfoList=csvgen.generateIndexDict(self.file, _start_word_, keyField) csvgen.writeDictToCSV(csvFile, indexInfoList) self.logger1.info("csv updated---"+csvFile) indexdict=indexInfoList inputJson=self.parseAndGenerateInputMap(indexdict); filename =_input_directory_+"ericsson_"+_obj_name_+".json" with open(filename, 'w') as f1: json.dump(inputJson, f1, indent=4) self.logger1.info("Json generated after parsing Input file ---"+str(inputJson)) except(FileNotFoundError): self.logger1.error("Input file missing:-"+self.file) raise except(Exception): self.logger1.error("Error while parsing input dump, check for the correct format") raise return filename