Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 04-03-2016, 09:39 PM   #1
iienderii
Junior Member
iienderii began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Apr 2016
Device: PC, Google Pixel 4XL
Question Request: template-making assistance for column built from other columns

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!
iienderii is offline   Reply With Quote
Old 04-03-2016, 09:44 PM   #2
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,358
Karma: 83238367
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?
eschwartz is offline   Reply With Quote
Advert
Old 04-03-2016, 10:25 PM   #3
iienderii
Junior Member
iienderii began at the beginning.
 
Posts: 9
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!
iienderii is offline   Reply With Quote
Old 04-03-2016, 10:46 PM   #4
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,358
Karma: 83238367
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by iienderii View Post
Quote:
Originally Posted by eschwartz View Post
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)
Can you explain this in more detail? Examples would be useful.

...

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?
eschwartz is offline   Reply With Quote
Old 04-03-2016, 11:30 PM   #5
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: 18,644
Karma: 30757202
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"
Does that describe what you want? It doesn't quite match what you said, but I can't think of a use for the alternatives.

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.
davidfor is offline   Reply With Quote
Advert
Old 04-04-2016, 12:14 AM   #6
BetterRed
null operator
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: 15,812
Karma: 18782456
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
BetterRed is offline   Reply With Quote
Old 04-04-2016, 10:32 AM   #7
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 24,861
Karma: 34300019
Join Date: Aug 2009
Location: The Central Coast of California
Device: K4NT(Fixed,New Bat.), Galaxy Tab A, Kobo Aura2
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.

use Save the Searches to periodically fill in the blanks
theducks is offline   Reply With Quote
Old 04-04-2016, 09:45 PM   #8
iienderii
Junior Member
iienderii began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Apr 2016
Device: PC, Google Pixel 4XL
Thumbs up

Quote:
Originally Posted by eschwartz View Post
Can you explain this in more detail? Examples would be useful.

...

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?
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.'
Attached Thumbnails
Click image for larger version

Name:	calibre example.PNG
Views:	165
Size:	8.9 KB
ID:	147603  
iienderii is offline   Reply With Quote
Old 04-04-2016, 10:10 PM   #9
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: 18,644
Karma: 30757202
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by iienderii View Post
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.'
So, in pseudo code terms this is:
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"
I don't use the template language enough to write it without some experimentation. I can do that tonight.

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.
davidfor is offline   Reply With Quote
Old 04-04-2016, 10:27 PM   #10
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,358
Karma: 83238367
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'
    )
);
eschwartz is offline   Reply With Quote
Reply

Tags
column settings, custom column, custom columns, template, template language

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 03:05 AM.


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