Emacs CSV mode

Emacs CSV mode

I’m loving how I find ways to use Emacs to solve problems in my daily work. Especially my nine-to-five job in DevOps.

My company provides email security solutions for Partner channels. Typically my team is rather hands-off with regard to the customer/partner needs. Those typically bubble up as features/bugs and we work on those. Occasionally we have an ask that requires our team—SUPER small team—to go and gather, collect, or even create a tool that provides a customer directly with data.

Today was that day.

A customer requested the mailbox quotas for each of their user. Preface: this customer is the only customer that ever requests this information; however, usually it’s a one-off user request. This time they wanted the data for all users; 200-ish.

We have provided this data via the doveadm quota command in the past. This command with a username queries the backend db and provides the output. Looking at the Doveadm Quota docs I honed in on the -F command: pass a file. NICE.

I jumped into our proprietary console and exported a .csv of the users for this domain. Easy.

I now had a file that provided a comma separated list that matches the following:

Username,First Name,Last Name,Email,User Type

I spent about five minutes thinking about how to extract the only field I needed: Email.

I landed on csv-mode. I easily installed this in my Doom Emacs by adding (package! csv-mode) to my packages.el and reloaded my Doom.

From there, the documentation was very easy: csv-kill-fields and delete the first line.

The result is a listed document containing only the user email addresses. I fed that to doveadm quota -F and done.

Emacs is far more than a text editor. It’s a true Swiss Army knife.