View Single Post
Old 04-04-2018, 04:17 AM   #10
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,450
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Tatjana View Post
I don't do this because I am an historian, I do this because I love one, because I can do it, and if i don't do this, I am afraid nobody else will for a very long time.
This inspires me to give you a solution. You can use a custom template function in a "column built from other columns".

The steps:
  1. Create the template function by going to Preferences / Advanced / Template Functions.
  2. Give the template a name. In this example I named it length_of_longest_author.
  3. Put a -1 in the Argument count box because the function takes no arguments.
  4. Put this text in the Program code box:
    Code:
    def evaluate(self, formatter, kwargs, mi, locals):
    	authors = mi.get('authors')
    	if authors:
    		return max([len(a) for a in authors])
    	return 0
    The following screen capture shows the example
    Click image for larger version

Name:	Clipboard01.jpg
Views:	217
Size:	223.9 KB
ID:	163238
  5. Create a custom column "built from other columns. Name it whatever you want. Set the template to
    Code:
    program: length_of_longest_author()
    using the name you used for the custom template function. Set the Sort/Search box to "Number". Check the "Show in Tag browser" box if you want to see the values in the tag browser. The following screen capture shows my example.
    Click image for larger version

Name:	Clipboard02.jpg
Views:	218
Size:	49.0 KB
ID:	163239
It will be interesting to see what performance this has on your large library.
chaley is offline   Reply With Quote