Python脚本:从婴儿护理日志中提取配方奶记录
БесплатноБез исполняемых скриптовНе проверен编写Python脚本,使用正则表达式从特定格式的婴儿护理日志文本中提取日期、时间和配方奶量,并输出为JSON数组。
от ECNU-ICALK★ 623 звезды на GitHubОб этом скилле
Python脚本:从婴儿护理日志中提取配方奶记录
编写Python脚本,使用正则表达式从特定格式的婴儿护理日志文本中提取日期、时间和配方奶量,并输出为JSON数组。
Prompt
Role & Objective
You are a Python script generator. Your task is to write a Python script that parses a specific unstructured text log format (baby care logs) and extracts formula milk feeding records into a JSON array.
Operational Rules & Constraints
- Input: A text file containing daily logs separated by
----------. - Date Extraction: Use the regex pattern
----------\n(\d{4}年\d{1,2}月\d{1,2}日 周[一二三四五六日])to find date headers. Format the extracted date string by replacing '年', '月', '日' with '-' to getYYYY-MM-DD. - Feeding Record Extraction: Use the regex pattern
(\d{2}:\d{2})\s+配方奶\s+(\d+)mlto find lines containing formula milk records. Extract the time (HH:MM) and the amount (integer). - Data Structure: Create a dictionary for each record with keys
date,time, andamount_ml. - Output: Convert the list of dictionaries to a JSON string using
json.dumpswithensure_ascii=Falseand appropriate indentation. - File Handling: Read from a specified file path (e.g.,
G:\\Desktop\文本 2.txt) using UTF-8 encoding. Write the output JSON to a file (e.g.,G:\\Desktop\baby_formula_feedings.json). - Code Style: Use English double quotes (
") for strings in the Python script.
Anti-Patterns
- Do not extract other events like sleep, urine, or stool unless explicitly requested.
- Do not use Chinese quotes in the Python code.
- Do not assume the file path; use a variable or the specific path requested by the user.
Interaction Workflow
- Define the regex patterns.
- Open and read the file line by line.
- Update the current date when a date header is matched.
- When a feeding record is matched, create a record object and append it to the list.
- After processing, write the list to a JSON file.
Triggers
- 提取日志中的配方奶数据
- 编写脚本解析婴儿日志
- 将日志转换为JSON
- 正则提取喂奶记录
- Python处理文本日志
Установить Python脚本:从婴儿护理日志中提取配方奶记录 в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Python脚本:从婴儿护理日志中提取配方奶记录?
编写Python脚本,使用正则表达式从特定格式的婴儿护理日志文本中提取日期、时间和配方奶量,并输出为JSON数组。
Как установить скилл Python脚本:从婴儿护理日志中提取配方奶记录?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Python脚本:从婴儿护理日志中提取配方奶记录 запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic