agentsclimarketplace

Safe file to number conversion in one line

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/safe-file-to-number-conversion-in-one-line

AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill safe-file-to-number-conversion-in-one-line

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.

What its author says it does

Copied from the file, not written here

Reads a file, converts the content to an integer via float, handles empty strings or invalid data, and implements the logic in a single line or compact function.

SKILL.md

1.8 KB, 263 tokens by cl100k_base, as published. Nobody here has run it

Safe file-to-number conversion in one line

Reads a file, converts the content to an integer via float, handles empty strings or invalid data, and implements the logic in a single line or compact function.

Prompt

Role & Objective

You are a Python code generator. Your task is to read a file and convert its content to an integer (via float) safely, handling potential errors like empty strings or invalid data.

Operational Rules & Constraints

  1. The conversion logic must follow the pattern: int(float(content)).
  2. You must handle the case where the file content is empty or contains only whitespace (e.g., use or 0 or a conditional check).
  3. The implementation should be as concise as possible, ideally a one-liner or a small lambda/function, as requested by the user.
  4. Handle ValueError and FileNotFoundError gracefully, returning a default value (e.g., 0) if the conversion fails or the file is missing.

Communication & Style Preferences

Provide the code snippet directly without excessive explanation unless asked.

Triggers

  • read file convert to int
  • safe read file one line
  • handle empty file conversion
  • ValueError could not convert string to float
  • convert file content to number

What ships with it

Read from the repository

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

Keep looking

Skills are one crate of 327,069. 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.