🔃 CSV 列排序(按表头名或指定顺序重排)Sort CSV Columns
重排 CSV/TSV 的列:按表头名字母顺序,或按你给出的列号/列名列表自定义顺序。未列出的列可接在后面或丢弃。Reorder CSV/TSV columns: alphabetically by header name, or by a list of column numbers/names you give. Columns not listed can follow at the end or be dropped.
使用说明与常见问题How-to & FAQ
「CSV 列排序(按表头名或指定顺序重排)」是什么?What is the Sort CSV Columns tool?
重排 CSV/TSV 的列:按表头名字母顺序,或按你给出的列号/列名列表自定义顺序。未列出的列可接在后面或丢弃。Reorder CSV/TSV columns: alphabetically by header name, or by a list of column numbers/names you give. Columns not listed can follow at the end or be dropped.
如何使用「CSV 列排序(按表头名或指定顺序重排)」?How do I use the Sort CSV Columns tool?
在「CSV 列排序(按表头名或指定顺序重排)」中,把内容粘贴或输入到上方输入框,按需设置「方式」、「列顺序(列号或表头名)」、「其余列」,结果会实时显示在下方,点击「复制结果」即可复制。Paste your CSV, then either type the new order in "Column order" (for example 3,1,2 or city,name,age) or switch the Mode to sort alphabetically by header. Under "Other columns", choose whether unlisted columns follow at the end or are dropped. Click "Copy result" to copy the output.
自定义顺序怎么写?How do I write a custom order?
用逗号或空格列出列号或表头名,例如 3,1,2、2 1 或 city,name,age。List column numbers or header names with commas or spaces: 3,1,2, 2 1, or city,name,age.
“其余列接在后面”是什么意思?What does Keep remaining columns after mean?
你列出的列按给定顺序排在前面,没提到的列按原来的相对顺序接在末尾;选“丢弃”则只保留列出的列。Listed columns come first in your order; unlisted ones keep their relative order at the end. Drop keeps only the listed columns.
输入和输出是什么样的?What does the input and output look like?
例如在「CSV 列排序(按表头名或指定顺序重排)」中输入 a,b,c ⏎ 1,2,3,「列顺序(列号或表头名)」设为 3,1,2,输出为:c,a,b ⏎ 3,1,2(⏎ 表示换行)。With "Column order (numbers or headers)" set to 3,1,2, the input a,b,c ⏎ 1,2,3 becomes c,a,b ⏎ 3,1,2 (⏎ marks a line break).
有哪些选项可以调整?What options can I adjust?
「CSV 列排序(按表头名或指定顺序重排)」的设置:「方式」可选 按指定顺序、按表头名排序(默认 按指定顺序);「列顺序(列号或表头名)」默认 3,1,2;「其余列」可选 其余列接在后面、丢弃未列出的列(默认 其余列接在后面);可勾选:「第一行是表头」(默认勾选)。改动任一选项后结果会按新设置重新生成。You can adjust "Mode" — Custom order / Alphabetical by header (default: Custom order); "Column order (numbers or headers)" (default: 3,1,2); "Other columns" — Keep remaining columns after / Drop columns not listed (default: Keep remaining columns after); and the "First row is a header" (on by default) checkbox. The result updates as soon as you change a setting.
行长度不一致(有的行字段多、有的行字段少)时会怎样?What happens when rows have different numbers of fields?
不会凭空补字段,也不会删掉字段:操作只作用于每行实际存在的字段,每行保持自己原来的长度。比如某行没有要处理的那一列,这一行就原样保留。检测到这种行时,结果下方会有一行提示说明有几行。需要统一列数时,请用“CSV 补齐不完整行”。No fields are invented or dropped: the operation only touches the fields each row actually has, and every row keeps its own length. If a row does not have the column being changed, that row is left as it is. When such rows are found, a one-line note below the result says how many. To give every row the same number of fields, use Fill Incomplete CSV Records.
表头里有重名的列,或者同一列写了两次会怎样?What if two columns share a header name, or I list a column twice?
按名字选择时只会用到第一个同名列,结果下方会给出提示,列出所有同名列的位置;要选其他同名列请直接写列号。同一列写了两次(例如 1,1)只算一次,也会提示是哪一列。A header name picks the first column with that name, and a note below the result lists every column that shares it; use a column number to pick another one. A column listed twice (for example 1,1) is used once, and the note names it.
代码或数据会被上传吗?Is my code or data uploaded?
不会。「CSV 列排序(按表头名或指定顺序重排)」完全用 JavaScript 在本地运行,适合处理含有密钥、内部接口等敏感内容的数据。No. The Sort CSV Columns tool runs entirely in local JavaScript, so it is safe for data containing keys or internal endpoints.
「CSV 列排序(按表头名或指定顺序重排)」免费吗?需要注册吗?Is the Sort CSV Columns tool free? Do I need an account?
「CSV 列排序(按表头名或指定顺序重排)」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Sort CSV Columns tool is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.