加载文本丨路径
Load a .txt or .csv into the graph — straight from disk
- 文本
- 文件路径
ComfyUI is weirdly resistant to "just read a text file from a path you type." The stock loader lives in input/ and works through a dropdown; the moment you want a file from an arbitrary absolute path - a prompt library, a CSV of tags, a settings file shared across workflows - you're fighting the tool. LoadPathText is the QING pack's answer: type or wire a path, get the file's contents as a string out. That's the whole node, and it's exactly what a workflow sometimes needs.
It's from ComfyUI-QING (display name "加载文本丨路径"). Display names are bilingual, so the outputs are labeled in Chinese: 文本 (text) and 文件路径 (file path).
How it works
You give it one input - file_path, a string that must be an absolute path to a .txt or .csv file. It reads the file with UTF-8 handling (utf-8-sig, which strips a BOM if present, and errors="replace" so weird bytes become � instead of crashing the run) and returns:
文本- the full file contents as a STRING.文件路径- the normalized path it actually used.
The normalization detail matters for one subtle case: the author's path handling is deliberately defensive. If the path isn't absolute, you get an error string back rather than a crash; if the file doesn't exist, you get "❌ 文件不存在: ..."; if the extension isn't .txt or .csv, you get a polite refusal. In every failure case it returns the error as the text output instead of raising - which means a broken path shows up as a string you can see, not a console traceback. That's a genuinely friendly design for a node beginners will misconfigure.
Where it fits
Three jobs. Prompt libraries: keep a curated set of prompts in a .txt on disk, load it here, and feed it to a ListItemGetter or TextSplitter (both in the same pack) to pick one. CSV-driven batch config: load a CSV of per-image parameters and let the graph iterate over the rows. Shared config across workflows: one text file, many workflows reading it - change the file, every workflow picks it up on next run.
The one thing to remember: this loads text, not images. It's the string-tier loader; the pack's image loaders (CustomLoadImageWithFormat, LoadImageFromURL) handle the visual side.
Installing
Part of ComfyUI-QING. ComfyUI Manager: search "ComfyUI-QING". Or:
cd ComfyUI/custom_nodes
git clone https://github.com/GAO-SHIQING/ComfyUI-QING
cd ComfyUI-QING
python install_dependencies.py # or: pip install -r requirements.txt
Restart ComfyUI. Pure pip deps, no models. China mirror: --mirror --auto. Python ≥ 3.9.
Gotchas
Three constraints, all visible in the error strings: absolute paths only (no ~/ or relative paths - the node checks os.path.isabs and refuses), only .txt and .csv (a .json or .md file gets refused even though it'd read fine), and the file must exist at read time. If you're on Windows, escape backslashes in the path string or use forward slashes - "E:/notes/prompts.txt" works fine. And because it reads the file fresh on every run (it's an output node), it doubles as a "reload config each run" primitive - edit the file, re-run, get new content, no cache clearing. That's a feature you'll grow to appreciate.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 文本 | STRING | — |
| 文件路径 | STRING | — |