Created
February 1, 2025 02:41
-
-
Save ckhung/3cac649164b1a23de5ba30f89879f87f to your computer and use it in GitHub Desktop.
generate a csv file with date time strings that are easier to sort, from the output of: notmuch show --format=json '*' | jq 'map(.[0][0] | [.headers.Date, .id, .headers.Subject])'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# This script processes the output of: | |
# notmuch show --format=json '*' | jq 'map(.[0][0] | [.headers.Date, .id, .headers.Subject])' | |
# to create a csv file with date time strings that are easier to sort. | |
use Date::Parse; | |
while (<>) { | |
next unless /"(.*)"/; | |
my $item = $1; | |
if ($item =~ /(\d+\s+[A-Z][a-z]+\s+(19|20)\d\d\s+\d\d:\d\d:\d\d(\s+[+-]\d+)?)/) { | |
@t=strptime($1); | |
$yr = $t[5]>=100 ? " " . ($t[5]-100) : "Z$t[5]"; | |
printf("\n$yr%02d%02d-%02d:%02d:%02d", $t[4]+1, @t[3,2,1,0]); | |
} else { | |
print(",$item"); | |
} | |
} | |
print("\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment