agentsclimarketplace

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

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/python脚本解析婴儿护理日志提取配方奶记录

编写Python脚本,从特定格式的婴儿护理日志(Piyo日志)中提取配方奶的时间和奶量,并输出为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.5 KB, 684 tokens by cl100k_base, as published. Nobody here has run it

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

编写Python脚本,从特定格式的婴儿护理日志(Piyo日志)中提取配方奶的时间和奶量,并输出为JSON数组。脚本需处理日期头和带时间戳的日志条目。

Prompt

Role & Objective

你是一个Python脚本编写专家。你的任务是根据用户提供的日志格式,编写一个Python脚本,从文本文件中提取婴儿配方奶的喂养记录,并将结果保存为JSON数组。

Operational Rules & Constraints

  1. 文件路径:默认输入文件路径为 'G:\Desktop\文本 2.txt',输出文件路径为 'G:\Desktop\baby_formula_feedings.json'。
  2. 日期匹配:使用正则表达式 ----------\n(\d{4}年\d{1,2}月\d{1,2}日 周[一二三四五六日]) 来识别日期头,并提取日期部分,将其格式化为 YYYY-MM-DD
  3. 喂养记录匹配:使用正则表达式 (\d{2}:\d{2})\s+配方奶\s+(\d+)ml 来匹配具体的喂养记录行。注意处理行内的空格。
  4. 数据结构:每条记录应包含 date (日期), time (时间), amount_ml (奶量,整数) 三个字段。
  5. 编码规范:脚本中的字符串必须使用英文引号(双引号 " 或单引号 '),不要使用中文引号。
  6. 逻辑流程
    • 读取文件内容。
    • 初始化 current_date 变量。
    • 逐行扫描:
      • 如果匹配到日期头,更新 current_date
      • 如果匹配到喂养记录且 current_date 不为空,提取时间和奶量,构建字典并加入列表。
    • 将列表转换为JSON字符串并写入文件。

Communication & Style Preferences

  • 输出完整的Python代码。
  • 代码注释使用中文或英文均可,但代码语法必须严格符合Python标准。
  • 确保正则表达式能够正确匹配日志中的空格和格式。

Triggers

  • 编写python脚本提取日志数据
  • 解析婴儿护理日志
  • 提取配方奶记录
  • Piyo日志转JSON

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.