본문으로 건너뛰기
cccskills
무료GitHub에 공개

text-file

Guidelines for handling text files

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md2.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Text Files Handling Specifications

Goals

  • Safely read text files without memory exhaustion.
  • Accurately detect encoding to avoid garbled characters.
  • Identify underlying patterns (e.g., Log formats, Markdown structure, delimiters).
  • Efficiently extract or search for specific information within large volumes of text.

Encoding & Detection

  • Encoding Strategy:
    • Default to utf-8.
    • If it fails, try utf-8-sig (for files with BOM), gbk/gb18030 (for Chinese context), or latin-1.
    • Use chardet or similar logic if encoding is unknown and first few bytes look non-standard.
  • Line Endings: Be aware of \n (Unix), \r\n (Windows), and \r (Legacy Mac) when counting lines or splitting.

Inspection

  • Preview: Read the first 10-20 lines to determine:
    • Content Type: Is it a log, code, prose, or a semi-structured list?
    • Uniformity: Does every line follow the same format?
  • Metadata: Check total file size before reading. If >50MB, treat as a "large file" and avoid full loading.

Querying & Reading (Large Files)

  • Streaming: For files exceeding memory or >50MB:
    • Use with open(path) as f: for line in f: to process line-by-line.
    • Never use .read() or .readlines() on large files.
  • Random Sampling: To understand a huge file's structure, read the first N lines, the middle N lines (using f.seek()), and the last N lines.
  • Pattern Matching: Use Regular Expressions (Regex) for targeted extraction instead of complex string slicing.
  • Grep-like Search: If searching for a keyword, iterate through lines and only store/return matching lines + context.

Data Quality

  • Truncation Warning: If only a portion of the file is read, clearly state: "Displaying first X lines of Y total lines."
  • Empty Lines/Comments: Decide early whether to ignore blank lines or lines starting with specific comment characters (e.g., #, //).

Best Practices

  • Resource Safety: Always use context managers (with statement) to ensure file handles are closed.
  • Memory Consciousness: For logs and large TXT, prioritize "find and extract" over "load and filter."
  • Regex Optimization: Compile regex patterns if they are used repeatedly in a loop over millions of lines.
  • Validation: After reading, verify the content isn't binary (e.g., PDF or EXE renamed to .txt) by checking for null bytes or a high density of non-ASCII characters.
  • Progress Logging: For long-running text processing, log progress every 100k lines or 10% of file size.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guidelines for handling CSV/Excel files

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

agentscope-ai/agentscope-samples3512026년 4월 10일 업데이트

database

무료

Guidelines for handling databases

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

agentscope-ai/agentscope-samples3512026년 4월 10일 업데이트

Guidelines for handling image files

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

agentscope-ai/agentscope-samples3512026년 4월 10일 업데이트

json-file

무료

Guildlines for handling json files

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

agentscope-ai/agentscope-samples3512026년 4월 10일 업데이트

agentscope-ai의 스킬 모두 보기

이 스킬의 문제 신고