Авторский курс Елизаровой НаталииAuthor's course by Nataliia Elizarova
Модуль 15 · Урок 15-27Module 15 · Lesson 15-27

Отчёт одной кнопкой: скрипт и .batA report in one click: a script and a .bat

Каждый месяц вы сводите одни и те же выгрузки в один и тот же отчёт? Пусть Claude Code один раз напишет скрипт. Дальше кладёте свежие выгрузки в папку, дважды щёлкаете по файлу — и через минуту готовый отчёт со сверкой итога. Без Claude, без ручных шагов, у любого коллеги.

Do you merge the same exports into the same report every month? Let Claude Code write a script once. From then on you drop fresh exports into a folder, double-click a file, and a minute later you have a finished report with a reconciled total. No Claude, no manual steps, on any colleague's laptop.

⏱ 15 минут⏱ 15 minutes 🎮 Тренажёр «Найдите ошибку»🎮 Drill: "Find the bug" ✅ Тест из 5 вопросов✅ A 5-question quiz 🔎 Проверено: ноябрь 2026🔎 Checked: November 2026

После урока вы сможетеAfter this lesson you will be able to

  • разложить регулярный отчёт на конвейер «выгрузки → скрипт → отчёт → кнопка»;
  • попросить Claude Code написать скрипт с правильными правилами;
  • сделать .bat, который не ломается у коллеги;
  • проверить отчёт и передать его другому человеку.
  • turn a regular report into a pipeline: "exports → script → report → button";
  • ask Claude Code to write a script with the right rules;
  • make a .bat that doesn't break on a colleague's laptop;
  • check the report and hand it over to someone else.
1

Словарик из пяти словA five-word glossary

СкриптScriptфайл с программой (у нас — на Python, .py), который делает отчёт по шагам, всегда одинаковоa file with a program (here in Python, .py) that builds the report step by step, the same way every time
.batмаленький файл Windows: двойной щелчок — и он запускает скриптa small Windows file: double-click it and it runs the script
ВыгрузкаExportисходный файл из учётной системы: продажи, остатки, планa source file from your system: sales, stock, plan
Относительный путьRelative pathпуть от папки скрипта («input\sales.xlsx»), а не от вашего ноутбука («C:\Users\Имя\…»)a path from the script's folder ("input\sales.xlsx"), not from your laptop ("C:\Users\Name\…")
ПересборкаRebuildповторный запуск скрипта после любой правки, чтобы отчёт отразил измененияrunning the script again after any change so the report reflects it
2

На пальцах: кофемашина вместо туркиIn plain words: a coffee machine instead of a pot

☕ Турка = Claude в чате каждый месяц☕ A pot = Claude in chat every month

Каждый раз заново: насыпать, залить, следить. Объясняете Claude задачу, проверяете, и в этот раз он может сделать чуть иначе.

Every time from scratch: measure, pour, watch. You explain the task to Claude, check it, and this time it may do it slightly differently.

🤖 Кофемашина = скрипт + .bat🤖 A machine = script + .bat

Один раз настроили — дальше кнопка. Результат одинаковый, нажать может любой, Claude для запуска не нужен.

Set it up once, then it's a button. Same result every time, anyone can press it, Claude isn't needed to run it.

Главная мысльKey idea Claude Code нужен, чтобы построить кнопку. Нажимает её потом кто угодно, хоть каждый день. Если задача повторяется чаще раза в месяц — это кандидат на кнопку. Claude Code is there to build the button. Anyone presses it afterwards, even daily. If a task repeats more than once a month, it is a candidate for a button.
3

Конвейер из четырёх звеньевA four-link pipeline

📥 Выгрузки📥 Exportsкладёте в папку inputyou drop them into input
→
🐍 Скрипт .py🐍 Script .pyчитает, считает, сверяетreads, calculates, reconciles
→
📊 Отчёт📊 Reportновый Excel или HTML в outputa new Excel or HTML in output
→
🖱 Кнопка .bat🖱 .bat buttonдвойной щелчок запускает всёa double-click runs it all

Так выглядит папка готового отчёта. Её можно скопировать на любой ноутбук или положить в общую папку отдела:

This is what a finished report folder looks like. It can be copied to any laptop or placed in the team's shared folder:

Отчет_план_факт\
  input\            ← сюда кладёте свежие выгрузки
  output\           ← сюда скрипт пишет отчёт с датой в имени
  report.py         ← скрипт (пишет Claude Code)
  RUN_report.bat    ← кнопка: двойной щелчок
  README.md         ← как запускать, что куда класть
Plan_vs_actual_report\
  input\            ← drop fresh exports here
  output\           ← the script writes the dated report here
  report.py         ← the script (written by Claude Code)
  RUN_report.bat    ← the button: double-click
  README.md         ← how to run, what goes where
4

Шаги 1–2: папка и запрос на скриптSteps 1–2: the folder and the script request

Шаг 1. Создайте папку отчёта и подпапку input. Положите туда выгрузки за один прошлый месяц — тот, для которого у вас уже есть правильный отчёт. Это ваш эталон: по нему проверите скрипт.

Step 1. Create the report folder and an input subfolder. Put in the exports for one past month — one for which you already have a correct report. That is your reference: you will check the script against it.

Шаг 2. Откройте Claude Code в этой папке (как — урок 15-24), включите режим плана (урок 15-25) и дайте задачу. Правила в запросе — главное: без них скрипт заработает только у вас и только сегодня.

Step 2. Open Claude Code in that folder (how — lesson 15-24), switch on plan mode (lesson 15-25) and give the task. The rules in the request matter most: without them the script works only for you and only today.

Запрос на скриптScript request

Я экономист «Долины напитков». В папке input лежат выгрузки: план и факт продаж по городам и SKU за месяц. Напиши скрипт report.py на Python, который делает отчёт «план/факт по городам»: план, факт, отклонение в тыс. литров и в %. Правила: 1) исходные файлы только читать, никогда не менять; 2) результат — новый Excel в папке output, в имени дата запуска; 3) все пути — от папки скрипта, никаких C:\Users\…; 4) в конце вывести в консоль итог плана и факта из исходника и из отчёта — они должны совпасть; 5) если файл отчёта открыт в Excel — понятное сообщение, а не падение; 6) в начале скрипта — описание: что делает, что читает, что пишет. Сначала покажи план и спроси, если что-то в выгрузках непонятно.

I'm an analyst at Valley Beverages. The input folder holds exports: planned and actual sales by city and SKU for a month. Write a Python script report.py that builds a "plan vs actual by city" report: plan, actual, variance in thousand litres and in %. Rules: 1) read source files only, never change them; 2) the result is a new Excel file in the output folder with the run date in its name; 3) all paths relative to the script's folder, no C:\Users\…; 4) at the end print the plan and actual totals from the source and from the report — they must match; 5) if the report file is open in Excel, show a clear message instead of crashing; 6) start the script with a description: what it does, what it reads, what it writes. Show the plan first and ask if anything in the exports is unclear.

Скрипт, который получится, будет примерно такой формы. Читать код не обязательно, но полезно узнать в нём свои правила:

The resulting script will look roughly like this. You don't have to read code, but it helps to recognise your rules in it:

report.py
"""Отчёт план/факт по городам.
Читает выгрузку input/sales.xlsx (не меняет её), пишет новый файл в output.
"""
from pathlib import Path
from datetime import date
import pandas as pd
HERE = Path(__file__).parent                     # путь от скрипта, а не C:\Users\...
df = pd.read_excel(HERE / "input" / "sales.xlsx")  # исходник только читаем
rep = df.groupby("Город")[["План", "Факт"]].sum()
rep["Откл, %"] = (rep["Факт"] / rep["План"] - 1) * 100
out = HERE / "output" / f"Отчет_план_факт_{date.today():%Y-%m-%d}.xlsx"
out.parent.mkdir(exist_ok=True)
try:
    rep.to_excel(out)
except PermissionError:
    raise SystemExit(f"Файл открыт в Excel, закройте его: {out.name}")
print("План: исходник", df["План"].sum(), "| отчёт", rep["План"].sum())
print("Факт: исходник", df["Факт"].sum(), "| отчёт", rep["Факт"].sum())
"""Plan vs actual report by city.
Reads input/sales.xlsx (never changes it), writes a new file to output.
"""
from pathlib import Path
from datetime import date
import pandas as pd
HERE = Path(__file__).parent                     # path from the script, not C:\Users\...
df = pd.read_excel(HERE / "input" / "sales.xlsx")  # source is read-only
rep = df.groupby("City")[["Plan", "Actual"]].sum()
rep["Var, %"] = (rep["Actual"] / rep["Plan"] - 1) * 100
out = HERE / "output" / f"Plan_vs_actual_{date.today():%Y-%m-%d}.xlsx"
out.parent.mkdir(exist_ok=True)
try:
    rep.to_excel(out)
except PermissionError:
    raise SystemExit(f"The file is open in Excel, close it: {out.name}")
print("Plan: source", df["Plan"].sum(), "| report", rep["Plan"].sum())
print("Actual: source", df["Actual"].sum(), "| report", rep["Actual"].sum())
5

Шаг 3: кнопка .bat — четыре правилаStep 3: the .bat button — four rules

ПравилоRuleПочемуWhy
Только латиница внутри .batLatin characters only inside the .batКириллица в .bat превращается в кракозябры, и cmd выполняет не те команды. Русские сообщения пишет скрипт .pyCyrillic in a .bat turns into gibberish and cmd runs the wrong commands. Russian messages come from the .py script
cd /d "%~dp0" в началеcd /d "%~dp0" at the startПереходит в папку, где лежит сам .bat. Тогда скрипт найдёт input и output у любого коллегиMoves into the folder where the .bat itself sits. Then the script finds input and output on any colleague's laptop
pause в концеpause at the endБез неё окно закроется сразу, и вы не увидите ни итог сверки, ни ошибкуWithout it the window closes at once and you see neither the reconciliation total nor the error
Имя с RUN_ в началеName starting with RUN_Коллега сразу видит, на что нажиматьA colleague immediately sees what to click
RUN_report.bat
@echo off
REM Plan vs actual report. Double-click to run.
cd /d "%~dp0"
python report.py
pause
@echo off
REM Plan vs actual report. Double-click to run.
cd /d "%~dp0"
python report.py
pause
Запрос на .bat.bat request

Сделай RUN_report.bat для запуска report.py двойным щелчком. Только ASCII-символы внутри, никакой кириллицы. В начале перейди в папку самого .bat, в конце pause. Все сообщения на русском пусть печатает report.py.

Make RUN_report.bat to run report.py with a double-click. ASCII characters only inside, no Cyrillic. Start by moving into the .bat's own folder, end with pause. Let report.py print all the human-readable messages.

6

Шаги 4–5: пробный запуск, сверка, пересборкаSteps 4–5: test run, reconcile, rebuild

Запустите .batRun the .batДвойной щелчок. В окне — итог плана и факта: исходник и отчётDouble-click. The window shows the plan and actual totals: source and report
Сверьте с эталономReconcile with the referenceИтог и 2–3 города — с отчётом, который вы делали руками за тот же месяцThe total and 2–3 cities against the report you made by hand for the same month
Не сошлось — к ClaudeDoesn't match — back to Claude«В отчёте Береговой 410, в эталоне 395. Найди причину»"The report says Beregovoy 410, the reference says 395. Find the cause"
Ловушка, на которую наступают всеThe trap everyone falls into Claude поправил скрипт, вы открыли старый отчёт — а там прежние цифры. Правка в скрипте не видна в отчёте, пока скрипт не запущен заново. Проверка промежуточных данных или кода не заменяет пересборку: после каждой правки — снова .bat и снова сверка. Claude fixed the script, you open the old report — and the numbers haven't changed. A change in the script isn't in the report until the script runs again. Checking intermediate data or the code doesn't replace a rebuild: after every fix — run the .bat again and reconcile again.
7

Шаг 6: чтобы работало у коллегиStep 6: so it works for a colleague

  • README.md рядом со скриптом: что класть в input, как запускать, где результат, кому писать при ошибке.
  • Никаких путей и имён вашего ноутбука в скрипте — только от папки скрипта.
  • Python у коллеги: что установить и какие библиотеки — тоже в README. Если в компании свои правила установки, спросите IT.
  • Открытый Excel не даёт записать файл. Отчёт должен закрываться перед запуском — или скрипт должен понятно об этом сказать.
  • README.md next to the script: what to put in input, how to run it, where the result is, whom to contact on errors.
  • No paths or names from your laptop in the script — only relative to the script folder.
  • Python on the colleague's laptop: what to install and which libraries — also in the README. If your company has install rules, ask IT.
  • An open Excel file blocks writing. The report must be closed before running — or the script must say so clearly.
Запрос на READMEREADME request

Напиши README.md для этой папки для коллеги, который никогда не видел Python: что установить, какие выгрузки и с какими именами класть в input, как запустить RUN_report.bat, где найти отчёт, как проверить итог, что делать при ошибке «файл открыт в Excel». Коротко, по шагам.

Write README.md for this folder for a colleague who has never seen Python: what to install, which exports with which names go into input, how to run RUN_report.bat, where to find the report, how to check the total, what to do on the "file is open in Excel" error. Short, step by step.

8

Тренажёр: найдите ошибкуDrill: find the bug

Шесть ситуаций из жизни. Что пошло не так?

Six real-life situations. What went wrong?

9

Практика: своя первая кнопка за 30 минутPractice: your first button in 30 minutes

Задание 1. Выберите отчёт.Task 1. Pick a report. Тот, что делаете руками каждый месяц из 1–3 выгрузок. Возьмите выгрузки и готовый отчёт за прошлый месяц — это эталон. One you build by hand every month from 1–3 exports. Take last month's exports and finished report — that's the reference.
Задание 2. Скрипт и кнопка.Task 2. Script and button. Папка, input, запрос из раздела 4 (поменяйте описание выгрузок и отчёта на свои), затем запрос на .bat из раздела 5. Folder, input, the request from section 4 (change the export and report description to yours), then the .bat request from section 5.
Задание 3. Сверка и передача.Task 3. Reconcile and hand over. Запустите, сверьте итог с эталоном, попросите README и дайте папку коллеге: сможет ли он запустить без вас? Run it, reconcile the total with the reference, ask for a README and give the folder to a colleague: can they run it without you?
10

Частые ошибкиCommon mistakes

ОшибкаMistakeКак правильноDo this instead
Каждый месяц просят Claude в чате сделать тот же отчётAsking Claude in chat for the same report every monthОдин раз — скрипт и кнопка; дальше без ClaudeOnce — a script and a button; then no Claude needed
Скрипт пишет поверх исходной выгрузкиThe script overwrites the source exportИсходники только читаем, результат — новым файлом с датойSources are read-only, the result is a new dated file
Проверили код — «всё правильно» — отчёт не перезапустилиChecked the code — "all correct" — didn't rerun the reportПосле каждой правки — запуск и сверка с эталономAfter every fix — run and reconcile with the reference
Русские слова в .batCyrillic words in the .bat.bat — только латиница, русское — в .py.bat — Latin only, Cyrillic — in the .py
Работает «только у меня»Works "only on my laptop"Относительные пути, README, проверка у коллегиRelative paths, a README, a test on a colleague's laptop
11

Готов ли отчёт к передаче коллеге: отметьте галочкойIs the report ready to hand over: tick it off

12

Проверьте себяCheck yourself

13

ШпаргалкаCheat sheet

КонвейерPipelineinput → report.py → output → RUN_report.batinput → report.py → output → RUN_report.bat
Правила скриптаScript rulesисходники только читать · результат новым файлом с датой · пути от папки скрипта · итог в консоль · описание в началеread sources only · result as a new dated file · paths from the script folder · totals to the console · a description at the top
Правила .bat.bat rulesтолько латиница · cd /d "%~dp0" · pause · имя RUN_…Latin only · cd /d "%~dp0" · pause · name RUN_…
После правкиAfter a fixснова запуск и сверка с эталономrun again and reconcile with the reference
ПередачаHand-overREADME + проверка на чужом ноутбукеREADME + a test on someone else's laptop
Итог урокаLesson summary Регулярный отчёт — это конвейер: выгрузки в input, скрипт считает и сверяет, новый отчёт с датой в output, двойной щелчок по .bat запускает всё. Claude Code пишет скрипт один раз по вашим правилам: исходники не трогать, пути от папки, итог в консоль. .bat — только латиница, переход в свою папку и pause. После каждой правки — пересборка и сверка с эталоном, а README делает кнопку доступной любому коллеге. A regular report is a pipeline: exports into input, a script that calculates and reconciles, a new dated report in output, and a double-click on the .bat runs it all. Claude Code writes the script once following your rules: don't touch sources, paths from the folder, totals to the console. The .bat — Latin only, move to its own folder and pause. After every fix — rebuild and reconcile with the reference, and a README makes the button usable by any colleague.
Made on
Tilda