|
![]() |
|
Thread Tools | Search this Thread |
![]() |
#1 |
Member
![]() Posts: 10
Karma: 10
Join Date: Apr 2016
Device: PC, Google Pixel 4XL
|
![]()
Hello!
Avid Calibre user here - I've enjoyed the tool for quite some time now. Here's my question: I have a library with a handful of customised columns. I'm wanting to create one of the 'custom columns built from other columns that behave like tags' which, when I populate another column with 'x' then a template will automatically be triggered which will populate the new column with 'y' Basically column x is a list. Of that list, half of them are considered 'primary' and half 'secondary' - this 'primary' or 'secondary' text needs to go into the 'column built from other columns' so I figure the template text will need the entire list, and the corresponding 'primary' or 'secondary' text associated with it (so that the other column can be populated. my only issue is that I'm not quite sure how I should do that. I didn't really see an example in the forum that met this specific goal (though I might have missed it). Hope someone else has already done this and has a few minutes to share their template code. Thanks for you time! |
![]() |
![]() |
![]() |
#2 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
I'd be happy to help, but I am not 100% sure what you want.
You have a comma-separated list, say, in column x. In column y, you want a sublist restricted to specific possible values? |
![]() |
![]() |
![]() |
#3 |
Member
![]() Posts: 10
Karma: 10
Join Date: Apr 2016
Device: PC, Google Pixel 4XL
|
You have a comma-separated list, say, in column x.
- Yes! Column X is a comma-separated list - with about 100 items In column y, you want a sublist restricted to specific possible values? - I think that's the case. Column Y will likely be titled 'pub_category' and will have 3 choices (primary, secondary, and other). Based on the logic of the template, I'd like to, for each item in column x's list, associate them with either primary, secondary, or other. I'd like for this to be automatic, hence the use of this type of custom column (hopefully) thanks again for any assistance! |
![]() |
![]() |
![]() |
#4 | |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
... e.g. If column y is "primary", which items in column x get selected. ... Also, what problem are you trying to solve with this custom column? |
|
![]() |
![]() |
![]() |
#5 |
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
|
iienderii: The pseudo code that I saw when I read this looks like:
Code:
primary_tags = ('a', 'b', 'c') secondary_tags = ('d', 'e', 'f') if column_x.contains_any_of(primary_tags): return "Primary" else if column_x.contains_any_of(secondary_tags): return "Secondary" return "Other" If I'm right, that "contains_any_of" should be able to be done with a "list_intersection" and a "count". I can't experiment at the moment, but if no-one else has suggested a way, I'll have a look when I get home. |
![]() |
![]() |
![]() |
#6 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,611
Karma: 29710338
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Perhaps have two columns - 'tags' and '#tags2'.
Use Bulk Search and Replace to move the secondary values out of 'tags' into '#tags2' for existing books Use a Group Search, all_tags, to search both, see Preferences->Searching. BR |
![]() |
![]() |
![]() |
#7 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,889
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
I am with BR on using simple (custom) columns whenever possible.
Columns built form other columns must be used when the contents is based upon a column that continuously varies (eg reading progress). Every calculation slows the application down. For (mostly) Static values, use Bulk S&R to pre-load the custom column. Pre-loading is a single time performance hit. ![]() ![]() |
![]() |
![]() |
![]() |
#8 |
Member
![]() Posts: 10
Karma: 10
Join Date: Apr 2016
Device: PC, Google Pixel 4XL
|
![]()
I have a column which shows the title of the publication (in this case, it's a magazine library). Of those collected, I have a custom column called 'Category.' That field is based on a separate lookup-type table where I just decided which magazines are either 'primary,' 'secondary,' or 'other.' I'd like the 'Category' column to automatically populate with a pre-determined 'primary,' 'secondary,' or 'other' based on what I choose for 'Magazine Title.'
|
![]() |
![]() |
![]() |
#9 | |
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
|
Quote:
Code:
primary_mags = ('New Scientist', 'PC Advisor', 'PC Magazine') secondary_mags = ('World', 'Some other Magazine') if magazine_title in primary_mags: return "Primary" else if magazine_title in secondary_mags: return "Secondary" return "Other" But, is this really worth it? If you have to manually set the magazine title, I'm not sure that automatically setting the category gains you much. Especially as you have to maintain the template with the list titles in each category. |
|
![]() |
![]() |
![]() |
#10 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
I think in this case it makes a lot more sense to create a search, e.g.
Search name "Primary" Code:
#magazine_title:"=New Scientist" or #magazine_title:"=PC Advisor" or #magazine_title:"=PC Magazine" or #magazine_title:"=PC Powerplay" or #magazine_title:"=PC Pro" or #magazine_title:"=PC World" or #magazine_title:"=Popular Science" But you can achieve the effect you want with this template: (change the three constants at the top to suit your needs) Code:
program: primary_listitems = 'New Scientist, PC Advisor, PC Magazine, PC Powerplay, PC Pro, PC World, Popular Science'; secondary_listitems = 'World'; title = '#magazine_title'; str_in_list( primary_listitems, ',', title, 'primary', str_in_list( secondary_listitems, ',', title, 'secodary', 'other' ) ); |
![]() |
![]() |
![]() |
Tags |
column settings, custom column, custom columns, template, template language |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to "copy" or combine tags in two columns not as a built column? | jecilop | Library Management | 7 | 09-04-2014 07:26 PM |
Custom yes/no column built from long text column | Philantrop | Library Management | 7 | 03-23-2013 07:44 PM |
A little template assistance please? | Belfaborac | Library Management | 2 | 06-17-2012 11:29 AM |
Making references to other fields in template functions | Ruskie_it | Library Management | 10 | 12-21-2011 10:53 PM |
Regex assistance request - importing books. | Belfaborac | Library Management | 2 | 10-24-2011 08:03 AM |