在Emacs中添加/删除列电子表格功能? [英] Add/remove column spreadsheet features in Emacs?
问题描述
abc | efg | 123 | xyz123abc | yes
xxx | bbb | cc | ddd | no
例如说,我想添加一个第3列默认值为1并删除第4列,因此数据将如下所示:
abc | efg | 1 | 123 |是
xxx | bbb | 1 | cc | no
我正在研究组织模式表作为起点,
| abc | efg | 123 | xyz123abc |
| xxx | bbb | cc | ddd |
| | | | |
我刚刚发现如何将数据导入SES(没有导入功能,但事实证明,您可以简单地yank分页数据),所以这个答案比使用表捕获更简单:)(除非你的数据包含选项卡,在这种情况下你需要解决) 。
SES是Emacs中的实际电子表格应用程序。有关详细信息,请参阅其信息节点:
Ch i d m ses
RET 或 M - : (infoses)
kbd> RET
处理数据:
- 转换您的原始数据至TSV,例如 M - % | RET TAB RET !
- 删除该文本(例如选择区域,然后 Cw )
- 创建一个临时缓冲区,并改为ses-mode: Cx b
* ses *
RET
Mxses-mode
RET
(当然, Ch m ,了解ses-mode及其关键字的描述) - 将数据转入电子表格: Cy
- 移动到要删除的列,并使用 Mk 将其删除
- 复制结果回到TSV格式的杀死环: Cx h x t
(即mark-whole-buffer
+ses-export-tsv
) - * ses *缓冲区与 Cx k RET
- 将修改的TSV数据转回原始缓冲区与 Cy
- 将选项卡转换回
|
s使用 M - %< kbd> TAB RET | RET !
警告:我实际上在我的标准配置下出现了SES的问题,但是在 emacs -q
。 YMMV。
Given delimited data in the following format, how can I insert and delete columns?
abc|efg|123|xyz123abc|yes xxx|bbb|cc|ddd|no
Say, for example, that I wanted to add a 3rd column with a default value of 1 and remove the 4th column so the data would look like this:
abc|efg|1|123|yes xxx|bbb|1|cc|no
I was looking into org-mode tables as a starting point, however it puts extra spaces around the data.
| abc | efg | 123 | xyz123abc | | xxx | bbb | cc | ddd | | | | | |
Well I just found out how to import data into SES (there are no "ses-import" functions, but it turns out you can simply yank tab-separated data), so this answer is even simpler than using table-capture :) (unless your data contains tabs, in which case you'll need to work around that).
SES is an actual spreadsheet application within Emacs. See its info node for details:
C-hidm ses
RET, or M-: (info "ses")
RET
To process the data:
- Convert your original data to TSV with, say, M-%|RETTABRET!
- Kill that text (e.g. select region, then C-w)
- Create a temporary buffer and change to ses-mode: C-xb
*ses*
RET
M-xses-mode
RET
(and of course, C-hm for a description of ses-mode, and its keybindings) - Yank the data into the spreadsheet: C-y
- Move point to the column to delete, and kill it with M-k
- Copy the result back to the kill ring in TSV format: C-xhxt
(i.e.mark-whole-buffer
+ses-export-tsv
) - Kill the *ses* buffer with C-xkRET
- Yank the modified TSV data back into the original buffer with C-y
- Convert the tabs back to
|
s with M-%TABRET|RET!
Caveat: I'm actually having issues yanking into SES under my standard config, but this process works fine under emacs -q
. YMMV.
这篇关于在Emacs中添加/删除列电子表格功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!