카피맨 카테고리 비어있는 부분 처리

This commit is contained in:
R5600U_PC 2024-06-03 07:37:52 +09:00
parent 06c01c6d90
commit 5e7b430689
4 changed files with 11 additions and 4 deletions

View File

@ -155,7 +155,7 @@ def parse_naver_shopping(keyword_id, keyword, isBranch, branchCount, json_data,
merged_price = 0
for index, product in enumerate(final_top_5_products):
price = product.get("item", {}).get("price")
price = int(product.get("item", {}).get("price"))
merged_price += price # 평균 가격 계산을 위해
merged_price = merged_price / len(final_top_5_products)

Binary file not shown.

View File

@ -829,11 +829,11 @@ class Ui_Dialog(QtWidgets.QDialog):
# self.timerLabel.setText(f"{minutes:02d}:{seconds:02d}")
def getMatchingUrlCount(self):
# 데이터베이스 연결 및 MatchingUrl 개수 조회
# 데이터베이스 연결 및 MatchingUrl 개수 조회
try:
conn = sqlite3.connect(self.db_name) # 데이터베이스 파일 이름을 self.db_name 변수에 저장
current_table = self.comboBox.currentText() # 현재 선택된 테이블 이름 가져오기
query = f"SELECT COUNT(*) FROM {current_table} WHERE MatchingUrl IS NOT NULL"
query = f'SELECT COUNT(*) FROM "{current_table}" WHERE MatchingUrl IS NOT NULL'
cursor = conn.cursor()
cursor.execute(query)
@ -2186,7 +2186,7 @@ class Ui_Dialog(QtWidgets.QDialog):
self.db_name = now.strftime('%Y-%m-%d-%H%M') + '_copyman' + '.db'
conn = sqlite3.connect(self.db_name)
# DB 생성 함수 호출 예시 (실제 구현 필요)
# DB 생성 함수 호출
create_db(self.db_name)
logger.debug("카피맨 DB생성 완료")
@ -2194,6 +2194,13 @@ class Ui_Dialog(QtWidgets.QDialog):
logger.debug("카피맨 데이터 : 카테고리', '가격', '상품명', '태그', '이미지URL' 읽기")
df = pd.read_excel(file_name, usecols=['카테고리', '가격', '상품명', '태그', '이미지URL'])
logger.debug("카피맨 엑셀파일 읽기 완료")
# '카테고리' 컬럼이 없거나 NaN인 경우 '카테고리1>카테고리2>카테고리3>카테고리4'로 대체
if '카테고리' not in df.columns or df['카테고리'].isnull().all():
df['카테고리'] = '카테고리1>카테고리2>카테고리3>카테고리4'
else:
df['카테고리'] = df['카테고리'].fillna('카테고리1>카테고리2>카테고리3>카테고리4')
# '카테고리' 데이터를 분리하고 필요한 만큼의 컬럼만 선택
categories = df['카테고리'].str.split(r'>|-', expand=True).fillna('')

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 130 KiB