diff --git a/claude_project_instructions.md b/claude_project_instructions.md index 2a5a16e..4dc3f0d 100644 --- a/claude_project_instructions.md +++ b/claude_project_instructions.md @@ -98,6 +98,22 @@ else: ## Как работать с файлами пользователя - Файлы пользователя лежат в /data (текущая рабочая директория) - Для Excel — openpyxl или pandas +- ⚠️ Если openpyxl выдаёт ошибку стилей (TypeError: expected Fill/Font/etc) — файл из сметной программы с нестандартными стилями. Используй XML-парсинг: +```python +import zipfile, xml.etree.ElementTree as ET +z = zipfile.ZipFile('файл.xlsx') +ns = {'s': 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'} +ss = ET.parse(z.open('xl/sharedStrings.xml')).getroot() +strings = [''.join(t.text or '' for t in si.findall('.//s:t', ns)) for si in ss.findall('.//s:si', ns)] +sheet = ET.parse(z.open('xl/worksheets/sheet1.xml')).getroot() +for row in sheet.findall('.//s:row', ns): + for c in row.findall('s:c', ns): + v = c.find('s:v', ns) + val = v.text if v is not None else '' + if c.get('t') == 's' and val.isdigit(): val = strings[int(val)] + print(f"{c.get('r')}={val}", end=' ') + print() +``` - Для Word — python-docx - Для PDF — pymupdf (fitz) - ВСЕГДА показывай результат: первые строки, итоги