Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 10-04-2018, 07:25 PM   #1
Montana Harper
book geek (she/her)
Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.
 
Montana Harper's Avatar
 
Posts: 115
Karma: 2029154
Join Date: Sep 2013
Location: Pacific Northwest
Device: iPhone 16 Pro Max, Kindle Paperwhite (10th gen)
Custom column built from word count column

I'd love to be able to use my word count column to populate a column with a pre-defined name based on the length of the book, e.g., 40k+ words = Novel, 17,500 to 39,999 words = Novella, etc.

I've already got the word count column (using the Count Pages plug-in), but I can't figure out the syntax for the template, or even if what I'm trying to do is actually possible. Any help would be greatly appreciated!

TIA!
Montana Harper is offline   Reply With Quote
Old 10-04-2018, 07:50 PM   #2
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,725
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by Montana Harper View Post
I'd love to be able to use my word count column to populate a column with a pre-defined name based on the length of the book, e.g., 40k+ words = Novel, 17,500 to 39,999 words = Novella, etc.

I've already got the word count column (using the Count Pages plug-in), but I can't figure out the syntax for the template, or even if what I'm trying to do is actually possible. Any help would be greatly appreciated!

TIA!
The first_matching_cmp function should do the trick - see ==>>Template Language: Relational functions

BR
BetterRed is offline   Reply With Quote
Advert
Old 10-04-2018, 08:09 PM   #3
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
I wrote a template for that a while ago in a discussion on the Kobo forum. See this post. I don't actually use it as a column, but use a slightly modified version to set colours based on the type.

And looking at it now, using first_matching_cmp, would be better:

Code:
program: 
words=raw_field('#words');
shelf_name=first_matching_cmp(words, 7500, 'Short Story',  17500, 'Novelette', 40000, 'Novella', 'Novel');
I haven't tested it, but it should be right.
davidfor is offline   Reply With Quote
Old 10-04-2018, 09:57 PM   #4
Montana Harper
book geek (she/her)
Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.Montana Harper ought to be getting tired of karma fortunes by now.
 
Montana Harper's Avatar
 
Posts: 115
Karma: 2029154
Join Date: Sep 2013
Location: Pacific Northwest
Device: iPhone 16 Pro Max, Kindle Paperwhite (10th gen)
Thumbs up

Thank you both! I got it working exactly as I wanted.



The documentation is a bit lacking in information about how to use general program mode with custom columns, so I wanted to note—for the benefit of future information seekers—that even though it doesn't look like the program is properly formatted when you paste it from a text editor into the template field when creating a custom column, if it saves properly it should work...assuming the program syntax is correct, of course!

My final template:
Code:
program:
words=raw_field('#words');
length=first_matching_cmp(words,
     1,'UNCOUNTED',
     1001,'Flashfic',
     7500,'Short Story',
     17500,'Novelette',
     40000,'Novella',
     70000,'Short Novel',
     180000,'Novel',
     'Novel Plus')
This flags entries with empty word-count fields as UNCOUNTED, so I know I need to run the Count Pages plugin on them (rather than assigning the label Flashfic to them, which would be incorrect).
Montana Harper is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A custom column built from other columns: simple math operations Joanna Calibre 26 06-07-2016 04:35 AM
Crash when adding a custom (built) column MidwestJen Library Management 13 12-06-2014 03:52 PM
Custom Column with word count index Tanjamuse Library Management 22 05-11-2014 08:18 PM
Date custom column built from a Y/N one? glos Library Management 3 08-25-2013 12:48 PM
Custom yes/no column built from long text column Philantrop Library Management 7 03-23-2013 07:44 PM


All times are GMT -4. The time now is 02:55 PM.


MobileRead.com is a privately owned, operated and funded community.