TSV To Table

Philippe Gaultier has an interesting post on making a table of project dependencies. He’s using Rust, for which there is a tool to produce a tab-delimited (TSV) file of dependencies. The problem, for Gaultier, is that the output is not very human readable.

His solution was to write an AWK script that converts the TSV file to a version of Markdown and then export that to HTML. It works well and produces nice output that he can share with his coworkers. Take a look at his post to see the results.

Not to be that guy but when I read his post I thought, “Gee, that seems like a lot of work. How would I do that in Emacs?” After a few moments thought, I realized that I was already doing exactly that. I have a TSV file that I export from my iPhone and want to turn into an Org table. I simple paste the TSV data into my file and call (org-table-create-or-convert-from-region '(16)) to reformat the data to Org-mode table format.

The '(16) parameter tells org-table-create-or-covert-from-region that the data is tab delimited. There are other possible delimiters, see the documentation for the details.

Again, not to be that guy but this is another example of how powerful and flexible Emacs is. Have some data you want to convert? Chances are Emacs already has a way of doing it. Even if it doesn’t, it’s generally pretty easy to add a bit of Elisp to do it. The worst case is you’ll have to write an external app—in AWK, or whatever—to convert the data in your Emacs buffer to the format you need. Regardless, the whole process can be handled without leaving Emacs.

This entry was posted in General and tagged . Bookmark the permalink.