10-10-2011, 09:56 AM | #1 |
Addict
Posts: 352
Karma: 103850
Join Date: Apr 2011
Device: Kindle NT
|
Custom columns question
At the moment I have two main tags like columns (tags and shelves from goodreads). I created another column - genres. I populate it with syncing with goodreads sync plug in.
What I want is to populate it from other columns too. Is it possible? I probably wouldn't be able to sync to custom column made from other columns or could I? Actually I just thought of a way. Don't know if it would work. I could sync to shelves column. And I could create a custom column for genres which would be from tags and shelves. Now the problem. The problem is that I want it to take only specific values like - historical, sci-fi, fantasy, contemporary and not take other tags like short etc. I want to extract only genres. Is it possible to make it add only those values which are determined before. Would it be possible to add new values later? I want to group all my tags - book length, genres, character etc. into columns. So instead of 150 tags I would have organized structure. Basically forget the syncing part. Just how to make a custom column from two columns which would extract only specific values? I'd appreciate any help. Hope it is possible. Last edited by Noughty; 10-10-2011 at 10:22 AM. |
10-10-2011, 11:32 AM | #2 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
One way to have the columns dynamically correct (reflect the values currently in the other two columns) is to use a composite column (a column built from other columns). These columns use the template language to construct the value. For example, the template Code:
{#column1}, {#column2} It is possible to extract values from columns. The problem is knowing what values to extract. If what you want to extract is a fixed set of values, then you probably can use something like: Code:
program: list_union( list_intersection(field('#textmult'), 'val1, val2', ','), list_intersection(field('#textmult'), 'val3, val4', ','), ',') |
|
10-10-2011, 11:42 AM | #3 |
Addict
Posts: 352
Karma: 103850
Join Date: Apr 2011
Device: Kindle NT
|
I have fixed values. I might only need to add new ones once in awhile. It's possible to add additional ones?
#textmulti is a function? No need to change that? So I have to fill in values and columns (tags, #shelf). val1, val2 - I should write - historical, fantasy etc? Where should I write the columns: tags and #shelf ? I should copy program into template? For such a noob I might gave a perfect library soon Thanks a lot for your help Last edited by Noughty; 10-10-2011 at 11:44 AM. |
10-10-2011, 12:00 PM | #4 | ||||||
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
I suggest that you read the documentation for the functions I used (docs are at http://manual.calibre-ebook.com/template_ref.html). That might help you understand what the template program is doing. |
||||||
10-10-2011, 01:12 PM | #5 |
Addict
Posts: 352
Karma: 103850
Join Date: Apr 2011
Device: Kindle NT
|
trying, tell me if something is wrong.
program: list_union( list_intersection(field('tags'), 'Historical, Fantasy, Sci-Fi, Contemporary, Military', ','), list_intersection(field('#shelf'), 'Historical, Fantasy, Sci-Fi, Military', ','), ',') This gives me result of only one genre. How to have multiple values in results? A book might be in military and historical. And the result should be Military, Historical, not just Military I read about list functions but can't really figure it out . |
10-10-2011, 01:20 PM | #6 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I can't say what is wrong. That program does allow multiple results, and works for me.
One things to look at: you must match the entire genre, not part of it. For example, Military.History will not be matched by Military. You must add all of the subgenres. Yes, this is a pain. I am considering adding a list_re function that will return a sublist of items in a list that match the pattern. I need to think about how this might be used. If the above does not point you in the right direction, please post the contents of 'tags' and '#shelf' for a book that doesn't produce the correct values. |
10-10-2011, 01:29 PM | #7 |
Addict
Posts: 352
Karma: 103850
Join Date: Apr 2011
Device: Kindle NT
|
Looks like it's working. Thank you so much
Last edited by Noughty; 10-10-2011 at 01:33 PM. |
10-11-2011, 06:21 AM | #8 |
Addict
Posts: 352
Karma: 103850
Join Date: Apr 2011
Device: Kindle NT
|
I wanted to ask if it is possible to transform values when I am extracting them.
For example I am making column for favorites. I have values like "Favorite series", "Favorite titles". In the new column I'd like to have just word "series", "titles" etc. Since column name is already favorites. I have similar situation with a couple more columns. |
10-11-2011, 08:18 AM | #9 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
The following program will remove the word "favorite " from every element in the list: Code:
program: list_union( re(list_intersection(field('tags'), 'Historical, Fantasy, Sci-Fi, Contemporary, Military', ','), 'favorite ', ''), re(list_intersection(field('#shelf'), 'Historical, Fantasy, Sci-Fi, Military', ','), 'favorite ', ''), ',') You are rapidly approaching the point where you are pushing the template language beyond its limits, both in expression power and performance. A custom template function could be written that does exactly what you want and has excellent performance, but my guess is that this isn't something you are prepared to do. The other possibility is to use the 'correct' name in the original column. |
|
10-11-2011, 08:46 AM | #10 |
Addict
Posts: 352
Karma: 103850
Join Date: Apr 2011
Device: Kindle NT
|
Thanks for the reply. I think that is the most complicated I will ever push
I even managed to edit all those functions to fit if I am extracting only from one column too. So my tags, shelves grouping now is reality instead of a dream |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Default value for custom columns? | rogue_librarian | Library Management | 5 | 08-08-2011 05:43 PM |
Custom Columns - How are you using yours? | nynaevelan | Library Management | 19 | 04-18-2011 12:42 AM |
Custom Columns Question | Greg Waddell | Calibre | 5 | 03-31-2011 12:34 AM |
0.7.46 and custom columns | meme | Library Management | 4 | 02-21-2011 04:21 AM |
Been away for a few releases...question about custom columns support | texasnightowl | Calibre | 3 | 10-14-2010 09:48 AM |