함수를 이용해서 딕셔너리에 값을 저장하기 일정한 값을 입력하는 코드를 작성할때 함수를 이용하여 저장 # 파일에서 인원수 구하기 def get_info_num(file, file_pre, p_date): sub_total, sub_gap, sub_spc, sub_gen, sub_error =get_compare_num(file, file_pre) lst_total, lst_gap, lst_spc, lst_gen, lst_error =get_pre_file_num(file) dic_data = { 'title': p_date, 'total': f"{lst_total}({sub_total})", 'gap': f"{lst_gap}({sub_gap})", 'spc..
판다스_엑셀파일을 한번 읽고 시트명을 이용해서 데이터프레임 만들기 데이터프레임을 만들때, 엑셀개체를 한버만 읽기 읽어온 객체를 이용해서 시트별로 데이터 프레임 만들기 # 파일에서 인원수 구하기 def get_pre_file_num(p_file): try: # 파일 한 번만 읽기 xls = pd.ExcelFile(p_file) # 각 시트의 데이터프레임 길이 계산 num_total = len(xls.parse('기초명부전체')) if '기초명부전체' in xls.sheet_names else 0 # xls.parse('시트명') 시트를 데이터프레임으로 불러오기. xls는 객체 num_gap = len(xls.parse('갑만기_명부')) if '갑만기_명부' in xls.sheet_names else 0 ..