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 01-08-2015, 11: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 11:54 PM.
bmix is offline   Reply With Quote
Old 01-09-2015, 12:44 AM   #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: 1,809
Karma: 428332
Join Date: Aug 2013
Location: Texas
Device: 10" Win10 Tablet w/Calibre64, CalibreSpy & Freda+
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, 01: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,400
Karma: 84711550
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 11:33 AM.
eschwartz is offline   Reply With Quote
Old 01-09-2015, 04:57 AM   #4
chaley
Grumpy old git
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: 9,407
Karma: 3007492
Join Date: Jan 2010
Location: UK
Device: Reader
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:19 AM
Custom column listing the tags and language dpierron Library Management 4 10-19-2012 08:24 AM
Download tags to a custom column atjnjk Library Management 8 01-18-2012 09:02 AM
Boolean custom column values sengian Library Management 4 01-05-2012 06:39 PM
Help with template for custom column from tags africalass Library Management 2 07-16-2011 12:47 PM


All times are GMT -4. The time now is 04:24 PM.


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