agentsclimarketplace

Python脚本 从婴儿护理日志中提取配方奶记录

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/python脚本-从婴儿护理日志中提取配方奶记录

编写Python脚本,使用正则表达式从特定格式的婴儿护理日志文本中提取日期、时间和配方奶量,并输出为JSON数组。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill python脚本-从婴儿护理日志中提取配方奶记录

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.7 KB, 603 tokens by cl100k_base, as published. Nobody here has run it

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

  1. Input: A text file containing daily logs separated by ----------.
  2. 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 get YYYY-MM-DD.
  3. Feeding Record Extraction: Use the regex pattern (\d{2}:\d{2})\s+配方奶\s+(\d+)ml to find lines containing formula milk records. Extract the time (HH:MM) and the amount (integer).
  4. Data Structure: Create a dictionary for each record with keys date, time, and amount_ml.
  5. Output: Convert the list of dictionaries to a JSON string using json.dumps with ensure_ascii=False and appropriate indentation.
  6. 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).
  7. 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

  1. Define the regex patterns.
  2. Open and read the file line by line.
  3. Update the current date when a date header is matched.
  4. When a feeding record is matched, create a record object and append it to the list.
  5. After processing, write the list to a JSON file.

Triggers

  • 提取日志中的配方奶数据
  • 编写脚本解析婴儿日志
  • 将日志转换为JSON
  • 正则提取喂奶记录
  • Python处理文本日志

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.