A몰과 B몰에서 내려받은 CSV를 합쳐 중복 주문을 제거하고, 채널·일자별 매출을 한 장으로 정리하는 자동화입니다. 형식이 달라도, 값이 비어 있어도, 행을 조용히 버리지 않고 표시합니다.A script that merges two store exports, removes duplicate orders, and produces a one-page daily sales summary. Different column names, blank cells and bad rows are handled — and flagged, never silently dropped.
날짜 형식 3종, 통화 표기 혼용, 빈 이메일, 중복 주문, 음수 금액이 섞여 있습니다. 실제 고객 파일에서 흔한 상태입니다.Three date formats, mixed currency strings, missing emails, duplicated orders and one negative amount — all common in real customer files.
| order_id | date | channel | amount | 문제Issue |
|---|---|---|---|---|
| A-1042 | 2026.11.15 | Shopify | "₩ 42,000" | 통화 문자열currency string |
| A-1043 | 15/11/2026 | Shopify | 18,000 | 중복 행duplicate row |
| A-1044 | (빈칸) | Shopify | 55,000 | 날짜 없음missing date |
| A-1047 | 2026-11-16 | Shopify | -18,000 | 음수 금액negative |
| B-2201 | 11/15/2026 | Naver | KRW 39,000 | 정상ok |
| 채널Channel | 주문Orders | 금액Amount |
|---|---|---|
| Shopify | 8 | 286,000 |
| Naver | 3 | 104,000 |
| Coupang | 3 | 120,000 |
| 합계Total | 14 | 510,000 |
* 예시 수치입니다. 실제 실행 결과는 out/summary.html에서 확인할 수 있습니다.* Illustrative figures. The actual run writes out/summary.html.
issues 열에 표시Bad rows kept and marked in an issues column외부 라이브러리 없이 표준 라이브러리만 사용합니다. 의뢰인 PC나 사내 서버 어디서든 그대로 돌아갑니다.Standard library only — it runs unchanged on a client PC or an internal server.
def parse_date(value):
for fmt in ("%Y-%m-%d", "%Y.%m.%d", "%d/%m/%Y", "%m/%d/%Y", "%Y%m%d"):
try:
return datetime.strptime(value.strip(), fmt).date()
except ValueError:
pass
return None # kept, flagged as "unreadable date"
# duplicate orders: keep the richer row, not simply the first one
if new_score > prev_score:
keyed[order_id] = row