textfile-to-string
Read raw pipe-delimited LMFDB strings from disk. Use whenever the user wants to load data from DATA/ as strings, asks "how do I read a data file", needs to locate the right file path, or is building a restore/load pipeline.
- License 许可
- GPL-3.0
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- textfile-to-string
- description
- Read raw pipe-delimited LMFDB strings from disk. Use whenever the user wants to load data from DATA/ as strings, asks "how do I read a data file", needs to locate the right file path, or is building a restore/load pipeline.
03 SKILL.md 正文
textfile-to-string
Purpose: Locate the right DATA/ file and return the pipe-delimited line(s) as Magma strings. These strings can then be passed to /string-to-lmfdb-object.
Step 1 — Find the path
SetLMFDBRootFolder(".");
path := get_lmfdb_clifford_order_path(cl); // DATA/orders/2.1
path := get_lmfdb_sl2_path(cl); // DATA/sl2/2.1
path := get_lmfdb_gamma0_path2(SL2O, alpha); // DATA/gamma0/<order>/<gamma0_label>
path := get_lmfdb_hecke_path(MS, beta); // DATA/gamma0_hecke/<order>/<gamma0_label>
path := get_lmfdb_conj_intersection_path(X); // DATA/conj_intersection/<order>/<sigma>/<alpha>
Step 2 — Read and split
// Multi-line files (orders, sl2): one object per line
lines := [H : H in Split(Read(path), "\n") | #H gt 0];
// Single-object files (gamma0 v2, CI, hecke)
lines := [H : H in Split(Read(path), "\n") | #H gt 0];
assert #lines eq 1;
line := lines[1];
Filter by label (multi-line files)
target := "2.1.m4.1W6TEV";
matched := [l : l in lines | Split(l, "|")[<label_col_index>] eq target];
The label is always the first alphabetical attribute — check *_ATTRS for the column index.
Checking existence before reading
if OpenTest(path, "r") then
lines := ...
else
// file does not exist
end if;
Edge cases
- Empty trailing newlines from
Splitmust be filtered (| #H gt 0). Read(path)errors if the file does not exist — guard withOpenTest.- For CI directories (all alphas for a given sigma), use
get_lmfdb_conj_intersection_dir+Pipe("ls ...")to enumerate files. SetColumns(0)is called inside path intrinsics; call it yourself if building a path manually.
04 同仓库更多 Skills
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
writing-plans
Use when you have a spec or requirements for a multi-step task, before touching code
verification-before-completion
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
using-superpowers
Use when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions
using-git-worktrees
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback
test-driven-development
Use when implementing any feature or bugfix, before writing implementation code