fix: XML-парсер для реальных смет + smart detector + тесты
XML reader fixes: - inlineStr, row positioning, column refs, rels namespace - Анализ: head + tail (не только первые 30 строк) - max_rows=999 для полного чтения смет Выводы по реальным файлам (Строительный Эксперт): - Итоги в столбце A, подписи в H (не наоборот) - Шифр в имени файла, не в ячейке - Сводный ССР не содержит шифров ЛС — только разделы - Batch работает для стандартных файлов (тест 20/20) - Для реальных файлов нужен Claude Code или доработка Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -127,21 +127,43 @@ def extract_zip(zip_path: str, dest_dir: str) -> list[str]:
|
||||
|
||||
async def analyze_structure(sample_files: list[str], target_file: str, task_description: str) -> dict:
|
||||
"""Use LLM to analyze file structure and generate processing script."""
|
||||
# Read samples
|
||||
# Read samples — head + tail to see structure AND totals
|
||||
samples = []
|
||||
for f in sample_files[:3]:
|
||||
data = read_xlsx_xml(f, max_rows=30)
|
||||
samples.append({
|
||||
'filename': Path(f).name,
|
||||
'sheets': {k: v[:15] for k, v in data.items() if k != '_error'},
|
||||
})
|
||||
data = read_xlsx_xml(f, max_rows=999)
|
||||
sample = {'filename': Path(f).name, 'sheets': {}}
|
||||
for k, v in data.items():
|
||||
if k == '_error':
|
||||
continue
|
||||
head = v[:15]
|
||||
tail = v[-50:] if len(v) > 50 else v[15:]
|
||||
# Compact: only non-empty rows
|
||||
head_compact = [[j, row[j]] for row in head for j in range(len(row)) if row[j]]
|
||||
tail_compact = []
|
||||
for i, row in enumerate(tail):
|
||||
row_idx = len(v) - len(tail) + i
|
||||
cells = [[j, row[j]] for j in range(len(row)) if row[j]]
|
||||
if cells:
|
||||
tail_compact.append({'row': row_idx, 'cells': cells[:6]})
|
||||
sample['sheets'][k] = {
|
||||
'total_rows': len(v),
|
||||
'head': head_compact[:30],
|
||||
'tail': tail_compact[:30],
|
||||
}
|
||||
samples.append(sample)
|
||||
|
||||
# Read target structure
|
||||
target_data = read_xlsx_xml(target_file, max_rows=40)
|
||||
target_info = {
|
||||
'filename': Path(target_file).name,
|
||||
'sheets': {k: v[:20] for k, v in target_data.items() if k != '_error'},
|
||||
}
|
||||
target_data = read_xlsx_xml(target_file, max_rows=50)
|
||||
target_info = {'filename': Path(target_file).name, 'sheets': {}}
|
||||
for k, v in target_data.items():
|
||||
if k == '_error':
|
||||
continue
|
||||
compact = []
|
||||
for i, row in enumerate(v[:30]):
|
||||
cells = [[j, row[j]] for j in range(len(row)) if row[j]]
|
||||
if cells:
|
||||
compact.append({'row': i, 'cells': cells[:8]})
|
||||
target_info['sheets'][k] = {'total_rows': len(v), 'rows': compact}
|
||||
|
||||
prompt = f"""Ты — эксперт по автоматизации сметного дела.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user