Merge branch 'main' of https://git.originalhome.ru/va1is/MacOS_Parsers
This commit is contained in:
commit
c4719913b3
@ -0,0 +1,3 @@
|
|||||||
|
[
|
||||||
|
"http://localhost:3005"
|
||||||
|
]
|
||||||
@ -272,16 +272,37 @@ class ImportApp(QMainWindow):
|
|||||||
if not path:
|
if not path:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
wb = openpyxl.load_workbook(path)
|
wb = openpyxl.load_workbook(path, data_only=True)
|
||||||
sheet = wb.active
|
sheet = wb.active
|
||||||
|
|
||||||
self.display_sheet(sheet)
|
# === читаем ВСЕ строки для обработки ===
|
||||||
|
all_data = [list(r) for r in sheet.iter_rows(values_only=True)]
|
||||||
|
if not all_data:
|
||||||
|
self.log("⚠️ Файл пуст.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self.headers = [str(h) if h else "" for h in all_data[0]]
|
||||||
|
self.loaded_data = all_data # ВСЁ содержимое для дальнейшей работы
|
||||||
|
|
||||||
|
# === только первые 50 строк показываем в таблице ===
|
||||||
|
preview_data = all_data[:51]
|
||||||
|
self.table.clear()
|
||||||
|
self.table.setRowCount(0)
|
||||||
|
self.table.setColumnCount(len(self.headers))
|
||||||
|
self.table.setHorizontalHeaderLabels(self.headers)
|
||||||
|
|
||||||
|
for r_idx, row in enumerate(preview_data[1:], start=0):
|
||||||
|
self.table.insertRow(r_idx)
|
||||||
|
for c_idx, value in enumerate(row):
|
||||||
|
self.table.setItem(r_idx, c_idx, QTableWidgetItem("" if value is None else str(value)))
|
||||||
|
|
||||||
self.log(f"📄 Загружен файл: {os.path.basename(path)} ({sheet.max_row} строк)")
|
self.log(f"📄 Загружен файл: {os.path.basename(path)} ({sheet.max_row} строк)")
|
||||||
# обновим список заголовков в таблице сопоставления
|
|
||||||
self.populate_map_table()
|
self.populate_map_table()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log(f"❌ Ошибка при чтении файла: {e}")
|
self.log(f"❌ Ошибка при чтении файла: {e}")
|
||||||
|
|
||||||
|
|
||||||
def display_sheet(self, sheet):
|
def display_sheet(self, sheet):
|
||||||
self.table.clear()
|
self.table.clear()
|
||||||
self.table.setRowCount(0)
|
self.table.setRowCount(0)
|
||||||
@ -358,14 +379,40 @@ class ImportApp(QMainWindow):
|
|||||||
origin_col = mapping.get("originPath", "")
|
origin_col = mapping.get("originPath", "")
|
||||||
path_col = mapping.get("path", "")
|
path_col = mapping.get("path", "")
|
||||||
result = []
|
result = []
|
||||||
|
seen_origins = set()
|
||||||
|
|
||||||
idx_origin = self.headers.index(origin_col) if origin_col in self.headers else -1
|
idx_origin = self.headers.index(origin_col) if origin_col in self.headers else -1
|
||||||
idx_path = self.headers.index(path_col) if path_col in self.headers else -1
|
idx_path = self.headers.index(path_col) if path_col in self.headers else -1
|
||||||
|
|
||||||
for r in rows:
|
for r in rows:
|
||||||
origin_val = (str(r[idx_origin]).strip() if idx_origin >= 0 and idx_origin < len(r) and r[idx_origin] else "")
|
origin_val = (
|
||||||
path_val = (str(r[idx_path]).strip() if idx_path >= 0 and idx_path < len(r) and r[idx_path] else "")
|
str(r[idx_origin]).strip()
|
||||||
if origin_val or path_val:
|
if idx_origin >= 0 and idx_origin < len(r) and r[idx_origin]
|
||||||
result.append({"originPath": origin_val, "path": path_val})
|
else ""
|
||||||
|
)
|
||||||
|
path_val = (
|
||||||
|
str(r[idx_path]).strip()
|
||||||
|
if idx_path >= 0 and idx_path < len(r) and r[idx_path]
|
||||||
|
else ""
|
||||||
|
)
|
||||||
|
|
||||||
|
# пропускаем полностью пустые строки
|
||||||
|
if not origin_val and not path_val:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# если originPath уже был, пропускаем (оставляем только первое вхождение)
|
||||||
|
if origin_val in seen_origins:
|
||||||
|
continue
|
||||||
|
|
||||||
|
seen_origins.add(origin_val)
|
||||||
|
|
||||||
|
# нормализуем разделители (чисто косметически)
|
||||||
|
path_val = " > ".join([p.strip() for p in path_val.split(">")])
|
||||||
|
|
||||||
|
result.append({"originPath": origin_val, "path": path_val})
|
||||||
|
|
||||||
|
self.log(f"🧩 Найдено уникальных originPath: {len(result)}")
|
||||||
|
|
||||||
|
|
||||||
# ===== PRODUCTS =====
|
# ===== PRODUCTS =====
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user