03-30-2019, 10:33 AM | #1 |
Junior Member
Posts: 9
Karma: 10
Join Date: Mar 2019
Location: Paris, France
Device: Kobo Aura Edition 2
|
If ... Then in custom column
Hi all,
First, sorry if this thread is a duplicate. I've made some research and I did not find any helpful topics regarding my skills in calibre customization ;p I would like to create custom columns that tells me if some custom metadata are missing or not. Data quality check plugin is not relevant in this case. example of check I want to realize : 1rst example : if #genre contains SF or Fantasy or Weird then populate the column with SFFF else empty I've tried with the first test but it doesn't work {#genre:contains('SF','SFFF',{null})} another example of test I want to realize : if #nationalite not in (fr, ca) and #translator is null and #VO-title is null then #customcolumn = "translation data missing" else empty I've tried different method but none of them actually works I suppose that I'm missing something important ;p thanks in advance |
04-02-2019, 06:53 PM | #2 |
Groupie
Posts: 180
Karma: 299
Join Date: Jul 2010
Location: Brampton ON
Device: Kobo, Kindle3
|
Marco,
This is just a quickie off the top of my head, so, experiment first and if it doesn't go as I indicate, I apologize for wasting your time. I'd try {#genre:contains('SF','SFFF',''} (that's TWO SINGLE QUOTES typed without a space). Now, you can STACK the test. {#genre:contains('SF','SFFF',{#genre:contains('MYS ','MYS&THR'}} if you want, but be careful. I'd start in a text editor and then make sure my brackets were there as you compose a seriously compound test for a custom column. When you have that all looking right, THEN I'd work on a copy, delete all carriage returns and extraneous spaces and use that to test. (just some experience talking) The key is that Null doesn't seem to be useful to what you are trying to do in terms of returned result. But I could be wrong. It's forever since CHaley guided my way through the template language for plugboards and custom columns. Now, if you want a compound RESULTS column, where it can be SFFF AND MYS&THR, then you have to sequentially run each test and add to the result when you get each positive. That's a program, which Calibre can do. I'll leave you to look it up. Hope that helps a little, GM |
04-03-2019, 04:47 AM | #3 | ||
Grand Sorcerer
Posts: 11,731
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: test(list_intersection('SF, Fantasy, Weird', field('#genre'), ','), 'SFFF', '') Quote:
Code:
program: test( strcat( list_intersection('fr, ca', field('#nationalite'), ','), field('#translator'), field('#VO-title') ), '', 'translation data missing') The template produces output only if the three expressions produce an empty value, determined by concatenating the results of the three expressions.
In effect, the template implements your expression altered using De Morgan's Laws Code:
if not (#nationalite in (fr, ca) or #translator is not null or #VO-title is not null) then "translation data missing" else empty Last edited by chaley; 04-03-2019 at 04:51 AM. Reason: Minor fixes |
||
04-04-2019, 06:11 AM | #4 |
Groupie
Posts: 180
Karma: 299
Join Date: Jul 2010
Location: Brampton ON
Device: Kobo, Kindle3
|
Good to see you stepping into my breech, sir. Marco is in good hands. GM
|
04-04-2019, 02:10 PM | #5 |
Junior Member
Posts: 9
Karma: 10
Join Date: Mar 2019
Location: Paris, France
Device: Kobo Aura Edition 2
|
Hi Gary and Charles
thanks a lot for your help. I used the General Program Mode as described by Gary and it works. Thanks to you, I know now how to program 'if... then... else...' using test(...) and list_intersection(...) Last edited by Marco24; 04-04-2019 at 02:12 PM. Reason: adding url for general program mode |
04-06-2019, 05:24 AM | #6 |
Groupie
Posts: 180
Karma: 299
Join Date: Jul 2010
Location: Brampton ON
Device: Kobo, Kindle3
|
Actually Marco, it was Chaley to the rescue. He's THE Man when it comes to this kind of stuff. He helped me eons ago and continues to help others. I appreciate being thanked for my small effort here, but the man to thank specifically is Chaley. GM
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom column built from word count column | Montana Harper | Library Management | 3 | 10-04-2018 09:57 PM |
Move selected data from series column to a new custom column | fvdham | Library Management | 3 | 06-02-2017 03:49 PM |
Custom column returns value based on value of another custom column? | calvin-c | Calibre | 3 | 09-14-2013 02:24 PM |
Custom yes/no column built from long text column | Philantrop | Library Management | 7 | 03-23-2013 07:44 PM |
how to move value(s) of tag column to a custom made column | zoorakhan | Library Management | 0 | 12-08-2012 03:53 AM |