Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 06-10-2015, 05:51 AM   #1
davidam2
Junior Member
davidam2 began at the beginning.
 
Posts: 6
Karma: 10
Join Date: May 2015
Location: Barcelona
Device: Cool-er
Smile Is possible nested sublist?

Good Morning.

When I send to disk (or device), I need to change the name:
- If contains many authors, only select first:
> authors:sublist(0,1,&)
- Select the surname of author (last word):
> authors:sublist(-1,0, )

Both sentences works fine, but I dont know how to combine them.

My Save Template is:
{authors:sublist(0,1,&)} - {series:|| }{series_index:0>2s|[|] - }{title} ({pubdate:sublist(-1,0,\,)})

AUTOR (only first) - SERIE [n] (if exists) - TITLE (YEAR)


Thanks!!
davidam2 is offline   Reply With Quote
Old 06-10-2015, 07:45 AM   #2
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: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
You must use either general program mode (GPL) or template program mode. Which you choose depends on where the complexity is. In your case, determining in the template that there is more than one author might be a challenge, which would push me to GPL.

Here is a guess about what you might want expressed in GPL.
Code:
program:
	a=field('author');
	first_author =  sublist(a, 0, 1, '&');
	last_author=cmp(count(a, '&'), 1, '', '', strcat(' / ', sublist(a, -1, 0, '&')));
	authors = strcat(first_author, last_author);
	rest = template('{series:|| }{series_index:0>2s|[|] - }{title} ({pubdate:sublist(-1,0,\,)})');
	strcat(authors, ' - ',rest)
chaley is offline   Reply With Quote
Old 06-10-2015, 10:52 PM   #3
unboggling
Wizard
unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.unboggling ought to be getting tired of karma fortunes by now.
 
Posts: 1,065
Karma: 858115
Join Date: Jan 2011
Device: Kobo Clara, Kindle Paperwhite 10
I use this for sending to device: {author_sort:sublist(0,1,&)}

That lists the first or only author in author_sort whether there are more than one or not. The lastname is listed first in author_sort. For me distinguishing between one or two or three or too many (authors in author_sort) is too much trouble for not absolutely important information on the device. But I keep only a few books on device at a time.

For saving to disk, I use {authors} which I have as firstname lastname

Last edited by unboggling; 06-10-2015 at 11:08 PM.
unboggling is offline   Reply With Quote
Old 06-11-2015, 07:36 AM   #4
davidam2
Junior Member
davidam2 began at the beginning.
 
Posts: 6
Karma: 10
Join Date: May 2015
Location: Barcelona
Device: Cool-er
Thanks chaley and unboggling.

I try how chaley says. I need to undestand GPL mode or Template Program mode. I will read the links and I will try.

I will respond if I have success... or not

I dont understand your code yet, but maybe I not explain correctly:
I need ONLY ONE AUTHOR AND ONLY HIS/HER SURNAME.
Chaley, your code make this? (I try to undestand it) THANKS!!


Last edited by davidam2; 06-11-2015 at 07:42 AM.
davidam2 is offline   Reply With Quote
Old 06-11-2015, 10:44 AM   #5
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: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by davidam2 View Post
I dont understand your code yet, but maybe I not explain correctly:
I need ONLY ONE AUTHOR AND ONLY HIS/HER SURNAME.
Chaley, your code make this? (I try to undestand it) THANKS!!

No, my code does not do that. Your example implied that you wanted the first author, and if there is more than one author then the last author as well.

If you want only the surname of the first author then we can probably use author_sort to get it easily. Something like the following in TPM
Code:
{author_sort:'re($, '^([^,]*).*', '\1')'} - {series:|| }{series_index:0>2s|[|] - }{title} ({pubdate:sublist(-1,0,\,)})
chaley is offline   Reply With Quote
Old 06-11-2015, 11:52 AM   #6
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,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
chaley, I understood the OP to be asking about first author's lastname.
Anyway, I would've used an author_sort sublist split on the "," -- it is more readable than a regex.
No need for TPM.

Last edited by eschwartz; 06-11-2015 at 11:54 AM.
eschwartz is offline   Reply With Quote
Old 06-11-2015, 12:00 PM   #7
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: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by eschwartz View Post
chaley, I understood the OP to be asking about first author's lastname.
Anyway, I would've used an author_sort sublist split on the "," -- it is more readable than a regex.
No need for TPM.
I used "re" because it has much higher performance than sublist, something that would matter if a similar template was used in a composite column. I also think that functions in single function mode are hard to read because of the lack of spacing. But of course, YMMV.
chaley is offline   Reply With Quote
Old 06-11-2015, 12:15 PM   #8
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,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Well, obviously it is harder to read, but so is TPM. That is why I prefer GPM, but neither of us used that.
(post #2 doesn't count)

Good point about performance.
eschwartz is offline   Reply With Quote
Old 06-12-2015, 03:01 AM   #9
davidam2
Junior Member
davidam2 began at the beginning.
 
Posts: 6
Karma: 10
Join Date: May 2015
Location: Barcelona
Device: Cool-er


Thanks Chaley!!! Thanks Eschwartz too!

I don't know because I didnt think to use author_sort with a sublist split on the ",".
I will use your regex code (higher performance).

davidam2 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested Span? Turtle91 ePub 4 05-20-2013 02:47 PM
need help with nested template Jade Aislin Library Management 2 11-30-2012 02:04 AM
Nested headings? crich70 Sigil 20 04-11-2011 10:44 AM
Content Nested collections fartang Amazon Kindle 1 04-09-2011 12:18 PM
Are Nested TOCs Possible? VikingDave Sony Reader 11 12-28-2007 07:58 PM


All times are GMT -4. The time now is 10:19 AM.


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