def parse_total_xls_file(xls_file,db,pricelist_name, wizard_obj): user = wizard_obj.postgres_config_id.db_user host = wizard_obj.postgres_config_id.host_name password = wizard_obj.postgres_config_id.db_user_pass utility_type = wizard_obj.categ_id and wizard_obj.categ_id.name or False reader = csv.DictReader(open(xls_file, 'r'), delimiter=",") final_lst = [] data_lst = [] file_gas = addons.get_module_resource('import_xls/csv_data', 'master_sheet_cng_gas.csv') if utility_type == 'Gas': product_lst,sheet_1_data_gas = first_sheet.sheet_1_total_gas_price(file_gas,reader,pricelist_name,utility_type) product_import = pricelist.import_pricelist_total_product(db,user,host,password,product_lst,utility_type) pricelist.import_pricelist_total_gas(db,user,host,password,sheet_1_data_gas,utility_type) elif utility_type == 'Electricity': product_lst,sheet_1_data_gas = first_sheet.sheet_1_total_gas_price(file_gas,reader,pricelist_name,utility_type) product_import = pricelist.import_pricelist_total_product(db,user,host,password,product_lst,utility_type) pricelist.import_total_pricelist_ele(db,user,host,password,sheet_1_data_gas,utility_type) final_lst += sheet_1_data_gas return final_lst
def parse_sse_xls_file(xls_file,db,pricelist_name, wizard_obj): user = wizard_obj.postgres_config_id.db_user host = wizard_obj.postgres_config_id.host_name password = wizard_obj.postgres_config_id.db_user_pass utility_type = wizard_obj.categ_id and wizard_obj.categ_id.name or False rb = xlrd.open_workbook(xls_file,formatting_info=False,on_demand=False, ragged_rows=False) final_lst = [] data_lst = [] worksheet = rb.sheet_by_index(0) col_values = worksheet.row_values(0) # worksheet = rb.sheet_by_name(sheet) final_lst = [] data_lst = [] file_gas = addons.get_module_resource('import_xls/csv_data', 'master_sheet_cng_gas.csv') if utility_type == 'Gas': sheet_1_data_gas = first_sheet.sheet_1_sse_gas_price(file_gas,col_values,worksheet,pricelist_name,utility_type,rb) pricelist.import_pricelist_sse_gas(db,user,host,password,sheet_1_data_gas,utility_type) elif utility_type == 'Electricity': stop product_lst,sheet_1_data_gas = first_sheet.sheet_1_total_gas_price(file_gas,reader,pricelist_name,utility_type) product_import = pricelist.import_pricelist_total_product(db,user,host,password,product_lst,utility_type) pricelist.import_total_pricelist_ele(db,user,host,password,sheet_1_data_gas,utility_type) final_lst += sheet_1_data_gas return final_lst