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 01-08-2015, 10:45 PM   #1
bmix
Member
bmix began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Mar 2014
Location: Budapest/Hungary
Device: Kindle4,reMarkable2,MoonReader Pro
Question How can I boolean OR several tags into one custom column?

Hi,

I tried setting up a Usercolumn (user defined custom tags) because I want to use it to flag the book as part of a Kindle Collection, using the Collections plugin's import/export feature, that reads/fills this custom colum.

The column shall be named "Philosophy & Essays" if any of the tags of the book contain ("Philosophy" OR "Philosophie" OR "Essay" OR "Essays" OR "History" OR "Geschichte"). So, basically, I want to automate the addition of a flag.

The template I used first was:

Code:
{tags:'contains($,"Philosophy","Philosophie & Essays", "")'}
But, obviously, this only checks for a sinlge tag. What I need is a boolean OR. There is the or(value, value, ...) function, but I do not know how to apply it in this context.

Code:
{tags:'contains($,or("Philosophy", "Philosophie"),"Philosophie & Essays", "")'}
does not solve it.

On this: What do you guys use in order to test-evaluate such templates? The search-input in the main interface for the library does not play well with this, since the contains() function has a string output as a result.

EDIT: I found the template test GUI. So the last question is answered.

Thanks, Andreas

Last edited by bmix; 01-08-2015 at 10:54 PM.
bmix is offline   Reply With Quote
Old 01-08-2015, 11:44 PM   #2
DaltonST
Deviser
DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.
 
DaltonST's Avatar
 
Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
Derive Genres

Trivial for the Derive Genres plugin. Just set the Custom Column in Configuration to be what your #customcolumn is (it defaults to #genre), then update the Boolean Tag rules .csv file accordingly. Follow the User Guide. Excel CANNOT be used because it is not UTF8 encoding compliant. Do not ignore the User Guide about UTF8 or the job will fail. Do not use Excel or try to fake it out. Waste of time. Follow the User Guide.

DaltonST
DaltonST is offline   Reply With Quote
Advert
Old 01-09-2015, 12:20 AM   #3
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,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Or just do it with a simple program template:

Quote:
in_list()

in_list(val, separator, pattern, found_val, not_found_val) – treat val as a list of items separated by separator, comparing the pattern against each value in the list. If the pattern matches a value, return found_val, otherwise return not_found_val.

Code:
program:

in_list(
	field('tags'),
	',',
	'^(Philosophy|Philosophie|Essay(s)?|History|Geschichte)$',
	'Philosophy & Essays',
	''
)

Last edited by eschwartz; 01-09-2015 at 10:33 AM.
eschwartz is offline   Reply With Quote
Old 01-09-2015, 03:57 AM   #4
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: 11,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Another way to do it that checks for exact matches in tags instead of containment:
Code:
program:
	t = field('tags');
	v = 'Philosophy, Philosophie, Philosophy & Essays, History, Geschichte';
	l = list_intersection(t, v, ',');
	test(l, 'Philosophy & Essays', '')
By exact match I mean that the tag 'History' should match but the tag 'Military History' should not.
chaley is offline   Reply With Quote
Reply

Tags
boolean, custom column, kindle collections, templates


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to move tags data into a new custom column smoothrolla Library Management 6 05-30-2018 07:19 AM
Custom column listing the tags and language dpierron Library Management 4 10-19-2012 07:24 AM
Download tags to a custom column atjnjk Library Management 8 01-18-2012 08:02 AM
Boolean custom column values sengian Library Management 4 01-05-2012 05:39 PM
Help with template for custom column from tags africalass Library Management 2 07-16-2011 11:47 AM


All times are GMT -4. The time now is 07:15 PM.


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