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
sesRET, or M-:(info "ses")RETTo process the data:
*ses*RETM-x
ses-modeRET(and of course, C-hm for a description of ses-mode, and its keybindings)
(i.e.
mark-whole-buffer+ses-export-tsv)|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.