08-30-2013, 10:36 PM | #1 |
null operator (he/him)
Posts: 20,570
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Composite Column
I have two Custom Columns of type Comma separated text, like tags... - Translators and Dramaturgs,
I would like to have a section in the Tag Browser that combines the values into a Collaborators section. The same name can appear in the Translators and Dramaturgs columns and I would want them merged in the Collaborators section. I tried creating Collaborators as User Category, and then adding to it from the Translators and Dramaturgs, but you get multiple "Fred Bloggs", one from the Translators and another from Dramaturg. If I added Authors to the mix I could end up with 3 "Fred Bloggs". Plus the fact that the User Category must be maintained manually. The other choice could be a Column built from other columns, behaves like tags. But how to merge the two lists is the question. Conceptually I want to write the template {#translators} merge with {#dramaturgs} - but can that be done practically? BR BTW - whilst the User Category wasn't suitable for this purpose, its looks like an interesting feature - eg one could categorise Authors into their primary Genre - Childrens, Fantasy, Science Fiction, Chick Lit, if they were economists then one could categorise them into Krugmanites and Friedmanites Last edited by BetterRed; 08-30-2013 at 10:55 PM. Reason: typo |
08-30-2013, 11:36 PM | #2 |
null operator (he/him)
Posts: 20,570
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
I figured out how to do with Metadata Edit Search and Replace in two steps,
1) put Translator into Collaborator 2) append Dramaturg into Collaborators That works great for fixing what's already in the Library, but how can it be automated so that the collaborator list is maintained as new books, translators and dramaturgs are added etc. BR |
Advert | |
|
08-31-2013, 02:55 AM | #3 |
Evangelist
Posts: 432
Karma: 1720909
Join Date: Mar 2011
Device: Voyage, K3
|
Maybe I'm missing something, but does
{#translators}, {#dramaturgs} do what you want? |
08-31-2013, 04:14 AM | #4 | |
null operator (he/him)
Posts: 20,570
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
The attachment shows four columns and the corresponding Tag Browser lists. The Dramaturg and Translators columns are what I entered The Collaborators column is what comes from the {#translators}, {#dramaturgs} template The All People is what I get when I use the 2 step Search and Replace process previously outlined What you see in All People is what I want - But I'd like for it to happen automatically, rather than as the result of an arbitrary manual process. Up until now I haven't used the Create columns from other columns, and I have avoided all but the most trivial use of templates. BR EDIT 1 : And I also tried '&' and 'and', I even tried 'xor' :lol: EDIT 2 : I think I found the function I probably need to use - list_union - but I've no idea how or where to use it . Last edited by BetterRed; 08-31-2013 at 06:14 AM. Reason: add Edit |
|
08-31-2013, 07:24 AM | #5 |
Evangelist
Posts: 432
Karma: 1720909
Join Date: Mar 2011
Device: Voyage, K3
|
{#translators:||,}{##dramaturgs}
won't show a comma in books with empty fields. But it looks like you want to use '&' instead of comma when separating groups of people? I want to learn more about the writing advanced templates in calibre, but have little use for them, so I don't know a lot. I think that to use the list_union class you write a Template Function and call that in the custom column. |
Advert | |
|
08-31-2013, 08:33 AM | #6 |
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
@BetterRed: fundamental problem. Apparently you checked the "Contains Names" box for the tags-like columns, making the item separator an ampersand instead of a comma. This option does not exist for composite columns. Their separator is always a comma. Your template must take that into account.
Something like the following will give you a comma-separated list of authors in the composite column. To avoid unhappiness when resplitting the column later to make tag browser entries, I turn first all commas in names into semicolons. You would need to change the parameters to the field function to be your column lookup names. Code:
program: l1 = re(field('#people'), ',', ';'); l2 = re(field('authors'), ',', ';'); list_union( re(l1, '&', ','), re(l2, '&', ','), ',' ) |
08-31-2013, 06:29 PM | #7 | |
null operator (he/him)
Posts: 20,570
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
I unchecked Contains Names on the two source columns and put the following into the Collaborator template - voila it works Code:
program:list_union(field('#dramaturg'),field('#translators'), ',') I've since read that if I double click on a Composite cell value I get the Edit Template dialogue. Which assumes the Composite column is shown in the spreadsheet, and in this case it isn't - seems a bit 'odd' - but I can overcome with a Collaborators View I found the Tweak for rearranging the Tag Browser - I can't recall how many times I've wished for something and then been able to find it, more often that not right where I would expect to find it BR Last edited by BetterRed; 08-31-2013 at 09:22 PM. |
|
09-01-2013, 03:41 AM | #8 | |
Evangelist
Posts: 432
Karma: 1720909
Join Date: Mar 2011
Device: Voyage, K3
|
Quote:
Out of curiosity (so I learn something from this(besides that checking Contains names means an & instead of a comma )), what does the program with list_union give you, that the simpler template doesn't? I understand that list_union is more powerful, but in this case, since you unchecked Contains Names, I can't see a difference in the collaborators column. |
|
09-01-2013, 03:53 AM | #9 | |
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
list_union deals both with duplicates and ensuring that there aren't any superfluous commas if one or the other field is empty. |
|
09-01-2013, 04:37 AM | #10 |
Evangelist
Posts: 432
Karma: 1720909
Join Date: Mar 2011
Device: Voyage, K3
|
Thanks chaley, I see now that I hadn't added a duplicate when I tried things out.
|
09-01-2013, 04:41 AM | #11 | |
null operator (he/him)
Posts: 20,570
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
I prefer to have ampersands because Translators and Dramaturgs are people. The same person may translate 'play a', dramaturg 'play b' and author 'play c', My real version creates a union of all three - but I had to find the Template editor to get a bigger canvas on which to paste chaley's block of code. I would never have found it without the manual BTW you don't have to double click the composite column to edit it, you can press F2! I never cease to be amazed at the attention Calibre developers give to the small details. BR Last edited by BetterRed; 09-01-2013 at 04:48 AM. |
|
09-01-2013, 04:46 AM | #12 |
Grand Sorcerer
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Navigate to any cell in the column and press F2.
|
09-01-2013, 04:58 AM | #13 | |
null operator (he/him)
Posts: 20,570
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
BR RU looking ovber my shoulder |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Plugboard, template, and custom composite column recipes | chaley | Library Management | 976 | 04-22-2024 06:29 PM |
Set value of another column from composite? | dirgeon | Library Management | 1 | 02-03-2013 11:40 AM |
[Custom Column - Composite] Template Help Requested | Ealdwulf | Library Management | 2 | 06-16-2012 04:58 AM |
Composite column or not ? | Bertrand | Library Management | 3 | 08-24-2011 01:27 AM |
Custom Composite Column | silentguy | Calibre | 4 | 11-24-2010 10:28 AM |