![]() |
#1 |
book geek (she/her)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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! |
![]() |
![]() |
![]() |
#2 | |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,725
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
BR |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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'); |
![]() |
![]() |
![]() |
#4 |
book geek (she/her)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 115
Karma: 2029154
Join Date: Sep 2013
Location: Pacific Northwest
Device: iPhone 16 Pro Max, Kindle Paperwhite (10th gen)
|
![]()
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') |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |