diff --git a/excel_processor.py b/excel_processor.py index 474f48e..d351916 100644 --- a/excel_processor.py +++ b/excel_processor.py @@ -64,7 +64,8 @@ class ExcelProcessor: def read_excel(self, file_path): """Excel 파일 읽기""" try: - self.df_original = pd.read_excel(file_path) + # 제품코드를 문자열로 읽기 위한 dtype 설정 + self.df_original = pd.read_excel(file_path, dtype={'제품코드': str}) self.format_type = self.detect_format(self.df_original) return True except Exception as e: @@ -82,6 +83,12 @@ class ExcelProcessor: if old_col in df.columns: df_mapped[new_col] = df[old_col] + # 보험코드 9자리 패딩 처리 + if 'insurance_code' in df_mapped.columns: + df_mapped['insurance_code'] = df_mapped['insurance_code'].apply( + lambda x: str(x).zfill(9) if pd.notna(x) and str(x).isdigit() else str(x) if pd.notna(x) else None + ) + # 업체명 추가 (기본값) df_mapped['supplier_name'] = '한의사랑' @@ -112,6 +119,12 @@ class ExcelProcessor: if old_col in df.columns: df_mapped[new_col] = df[old_col] + # 보험코드 9자리 패딩 처리 + if 'insurance_code' in df_mapped.columns: + df_mapped['insurance_code'] = df_mapped['insurance_code'].apply( + lambda x: str(x).zfill(9) if pd.notna(x) and str(x).isdigit() else str(x) if pd.notna(x) else None + ) + # 날짜 처리 (YYYYMMDD 형식) if 'receipt_date' in df_mapped.columns: df_mapped['receipt_date'] = df_mapped['receipt_date'].astype(str)