unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Carl Worth <cworth@cworth.org>
To: signmeup1337@cock.li, notmuch@notmuchmail.org
Subject: Re: Statistics about senders with notmuch possible?
Date: Fri, 07 Jan 2022 09:32:43 -0800	[thread overview]
Message-ID: <87o84n5u4k.fsf@wondoo.home.cworth.org> (raw)
In-Reply-To: <9fcfcd939fe28bc87fbdb3bb25323fd1@cock.li>


[-- Attachment #1.1: Type: text/plain, Size: 2159 bytes --]

On Mon, Dec 27 2021, signmeup wrote:
> I would like to create some kind of statistics to see from which sender
> I've got the most emails, having something like a TOP 10 list.
>
[ 4 more citation lines. Click/Enter to show. ]
> In the end of every year I delete all my emails, which are not marked as
> archive and this year I got over 4.000 and most of them are just
> notifications (like ebay, if someone buys something). But I really would
> like to figure out where else the most mails are coming from to avoid
> them in the next year.
>
> Is something like this possible with notmuch?

Yes, it's definitely possible. Being able to script up operations like
this that act on your email store has always been a primary design goal
of notmuch, so this isn't actually hard to do.

Given any sender address you can ask notmuch to count the emails sent
from that address. Such as:

        notmuch count from:cworth@cworth.org

And you can also use notmuch to generate a list of all sender email
addresses across all of your email, with:

        notmuch address --output=sender --output=address '*'

So you can take the output from that second command and then run the
first command with email address in the output.

Doing that all combined, and the sorting the result might look something
like the following (assuming you are using bash as your shell):

        for sender in $(notmuch address --output=sender --output=address
'*'); do count=$(notmuch count from:$sender); echo "$count $sender"; done |
sort -n

If you wanted to run this on a subset of your email, just change the '*'
to a search specification for the messages you want to match, (where '*'
will match all messages).

And of course, this is running a separate notmuch search for every
sender email address you have in all of your emails, (not only the top
10 like you really want), so this could take some time if you have a lot
of messages. I just tested with a small subset of my own email messages
(the 21k+ messages I have matching 'subject:notmuch') and the above
script took about 30 seconds on my laptop.

I hope that helps,

-Carl

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



      parent reply	other threads:[~2022-01-07 17:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27 22:57 Statistics about senders with notmuch possible? signmeup1337
2021-12-28 10:47 ` Michael J Gruber
2022-01-07 17:32 ` Carl Worth [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o84n5u4k.fsf@wondoo.home.cworth.org \
    --to=cworth@cworth.org \
    --cc=notmuch@notmuchmail.org \
    --cc=signmeup1337@cock.li \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).