def main(): excel_file = 'Z:/ALLPDF/SPIE-FULLTXT/2018005/SPIE期刊.xlsx' actual_filepath = 'Z:/ALLPDF/SPIE-FULLTXT/2018005/QK' table_list = excelTableByIndex(excel_file) report_type = 'QK' report_name = 'SPIE' filepath_in_computer = '/SPIE-FULLTXT/2018005/QK' new_excel_file = 'Z:/ALLPDF/SPIE-FULLTXT/2018005/SPIE期刊.new.xls' # step1:判断文件是否存在,如果没有缺失的文件,则继续往下执行 # fileExist(table_list, actual_filepath) # step2:更新字段,然后返回一个新的excel文件,并且文件名中带有.new,之后使用新生成的.xls文件进行后面的数据库插入操作, # 生成新的xls文件之后将这个函数注释掉 # updateData(excel_file, table_list, report_type, filepath_in_computer) # step3: 更新s_source中的数据,期刊用finalJournal,会议用finalMeeting,完成之后注释掉 if report_type == 'QK': finalJournal(new_excel_file) if report_type == 'HY': finalMeeting(new_excel_file) if report_type == 'report': finalReport(new_excel_file) if report_type == 'huibian': finalHuibian(new_excel_file) # step4:读取新生成的excel文件,然后取出需要的字段,对字段进行处理,转换成标准的格式 data_list = excelDataChange(new_excel_file, report_type, report_name) print(len(data_list)) # # # step5:将新数据插入对应的数据库表中 insertNewDataToS_data(data_list, report_name) # 根据id字段修改docid字段 changeDocidById(report_name)
def mainInsertErrorData(self): field_to_field_dict = self.mainGetFieldToFieldDict() excel_file = self.excel_filepath.get().replace('\\', '/') new_excel_file = excel_file.split('.')[0] + '.new.xls' report_name = self.report_name.get() data_list = excelDataChange(new_excel_file, report_name, field_to_field_dict) count1 = insertErrorData(data_list, report_name) count2 = changeDocidById(report_name) if count1 == count2: msgb.showinfo('congragulate!', 'you have inserted %d data into s_data, please check if the number equal the error_num.')
def mainInsertNewDataToS_data(self): field_to_field_dict = self.mainGetFieldToFieldDict() excel_file = self.excel_filepath.get().replace('\\', '/') new_excel_file = excel_file.split('.')[0] + '.new.xls' report_name = self.report_name.get() report_type = self.report_type.get() data_list = excelDataChange(new_excel_file, report_name, report_type, field_to_field_dict) count = len(data_list) count1 = insertNewDataToS_data(data_list, report_name) count2 = changeDocidById(report_name) if count == count2: msgb.showinfo('congragulate!', 'you have finished this excel file, please select a new excel file or close main window') else: msgb.showerror('error!', 'you have %s data insert into s_data failed, please check it!' % count1)