Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 08-30-2013, 10:36 PM   #1
BetterRed
null operator (he/him)
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: 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
BetterRed is offline   Reply With Quote
Old 08-30-2013, 11:36 PM   #2
BetterRed
null operator (he/him)
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: 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
BetterRed is offline   Reply With Quote
Advert
Old 08-31-2013, 02:55 AM   #3
tilia
Evangelist
tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.
 
tilia's Avatar
 
Posts: 432
Karma: 1720909
Join Date: Mar 2011
Device: Voyage, K3
Maybe I'm missing something, but does

{#translators}, {#dramaturgs}

do what you want?
tilia is offline   Reply With Quote
Old 08-31-2013, 04:14 AM   #4
BetterRed
null operator (he/him)
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: 20,570
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by tilia View Post
Maybe I'm missing something, but does

{#translators}, {#dramaturgs}

do what you want?
Thank you tilia, that was one of things I tried, unfortunately it doesn't seem to work.

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

.
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	197
Size:	79.8 KB
ID:	110263  

Last edited by BetterRed; 08-31-2013 at 06:14 AM. Reason: add Edit
BetterRed is offline   Reply With Quote
Old 08-31-2013, 07:24 AM   #5
tilia
Evangelist
tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.
 
tilia's Avatar
 
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.
tilia is offline   Reply With Quote
Advert
Old 08-31-2013, 08:33 AM   #6
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,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, '&', ','),
		','
		)
chaley is offline   Reply With Quote
Old 08-31-2013, 06:29 PM   #7
BetterRed
null operator (he/him)
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: 20,570
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by chaley View Post
@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, '&', ','),
		','
		)
chaley - at least I was on the right track with list_union

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 did that because the Custom Column dialogue only gives me one line for the template!

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.
BetterRed is offline   Reply With Quote
Old 09-01-2013, 03:41 AM   #8
tilia
Evangelist
tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.
 
tilia's Avatar
 
Posts: 432
Karma: 1720909
Join Date: Mar 2011
Device: Voyage, K3
Quote:
Originally Posted by BetterRed View Post
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
I've had the same experience

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.
tilia is offline   Reply With Quote
Old 09-01-2013, 03:53 AM   #9
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,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by BetterRed View Post
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 have considered adding the template editor to the context menu in the create/edit column dialog. It is just enough of a bother that I haven't felt motivated yet, especially given that I would never use it. I always edit templates on the spreadsheet, because I get immediate results and don't need to restart calibre.
Quote:
Originally Posted by tilia View Post
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
list_union deals both with duplicates and ensuring that there aren't any superfluous commas if one or the other field is empty.
chaley is offline   Reply With Quote
Old 09-01-2013, 04:37 AM   #10
tilia
Evangelist
tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.tilia ought to be getting tired of karma fortunes by now.
 
tilia's Avatar
 
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.
tilia is offline   Reply With Quote
Old 09-01-2013, 04:41 AM   #11
BetterRed
null operator (he/him)
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: 20,570
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by tilia View Post
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.
@tilia - the difference is shows up in the Tag Browser, if you look at my attachment you'll see the difference between Collaborators and All People. In my 'real' database I don't display the Collaborators in the spreadsheet.

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.
BetterRed is offline   Reply With Quote
Old 09-01-2013, 04:46 AM   #12
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,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by BetterRed View Post
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 as I don't use the mouse unless there's no other way.
Navigate to any cell in the column and press F2.
chaley is offline   Reply With Quote
Old 09-01-2013, 04:58 AM   #13
BetterRed
null operator (he/him)
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: 20,570
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by chaley View Post
I have considered adding the template editor to the context menu in the create/edit column dialog. It is just enough of a bother that I haven't felt motivated yet, especially given that I would never use it. I always edit templates on the spreadsheet, because I get immediate results and don't need to restart calibre.
list_union deals both with duplicates and ensuring that there aren't any superfluous commas if one or the other field is empty.
@chaley - mate, I have the column in my Show All View so I can sneak up on it with an F2. And another big

BR

RU looking ovber my shoulder
BetterRed is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 04:02 AM.


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