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 05-14-2017, 05:54 PM   #1
bttrflii
Junior Member
bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.
 
Posts: 9
Karma: 348
Join Date: May 2017
Device: Kindle Voyage
Metadata Plugboard Series Numbers

I've been using the Metadata Plugboard to include series information when I transfer books from my computer to my Kindle, but I have been unable to figure out how to get books with decimal places in the series information to sort properly because they lack the leading 0.

This is probably best shown by example, so...
  • Plugboard template: {series}{series_index:0>2s| |: }{title}
  • Whole-number example on my Kindle: Series-Name 03: Title
  • Another whole-number example: Series-Name 10: Title
  • Decimal-number example on my Kindle: Series-Name 2.50: Title

This means of course that 2.50 sorts *after* both the 03 and the 10 because the leading 0 is missing. Is there any way to get the 2.50 to be 02.50 without making 03 and 10 into 03.00 and 10.00? Not all series have the decimal books, and putting decimals in every series would get cluttered.

Thanks everyone. :)

Edit: Solution given by chaley in post #7.

Last edited by bttrflii; 05-16-2017 at 12:12 PM.
bttrflii is offline   Reply With Quote
Old 05-14-2017, 06:16 PM   #2
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,208
Karma: 16534692
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
Quote:
Originally Posted by bttrflii View Post
I've been using the Metadata Plugboard to include series information when I transfer books from my computer to my Kindle, but I have been unable to figure out how to get books with decimal places in the series information to sort properly because they lack the leading 0.

This is probably best shown by example, so...
  • Plugboard template: {series}{series_index:0>2s| |: }{title}
  • Whole-number example on my Kindle: Series-Name 03: Title
  • Another whole-number example: Series-Name 10: Title
  • Decimal-number example on my Kindle: Series-Name 2.50: Title

This means of course that 2.50 sorts *after* both the 03 and the 10 because the leading 0 is missing. Is there any way to get the 2.50 to be 02.50 without making 03 and 10 into 03.00 and 10.00? Not all series have the decimal books, and putting decimals in every series would get cluttered.

Thanks everyone.
You could try something like:
{series}{series_index:0>5.2f| |: }{title}
jackie_w is offline   Reply With Quote
Old 05-14-2017, 11:09 PM   #3
bttrflii
Junior Member
bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.
 
Posts: 9
Karma: 348
Join Date: May 2017
Device: Kindle Voyage
Quote:
Originally Posted by jackie_w View Post
You could try something like:
{series}{series_index:0>5.2f| |: }{title}
Thank you, jackie_w, but unfortunately that turns the 03 and 10 numbers into 03.00 and 10.00, which I would really like to avoid. I'd like to have only the 2.50 change into 02.50 if possible.
bttrflii is offline   Reply With Quote
Old 05-15-2017, 01:32 AM   #4
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,782
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by bttrflii View Post
Thank you, jackie_w, but unfortunately that turns the 03 and 10 numbers into 03.00 and 10.00, which I would really like to avoid. I'd like to have only the 2.50 change into 02.50 if possible.
You don't do it that way and your Kindle (ASCII) sort will be off.
You need the leading 0 for single digit indexes
theducks is offline   Reply With Quote
Old 05-15-2017, 09:59 AM   #5
bttrflii
Junior Member
bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.
 
Posts: 9
Karma: 348
Join Date: May 2017
Device: Kindle Voyage
Quote:
Originally Posted by theducks View Post
You don't do it that way and your Kindle (ASCII) sort will be off.
You need the leading 0 for single digit indexes
I can't quite figure out what you're trying to say. I *DO* want the leading zero, and I currently get a leading zero when the series number is a whole number. What I'm asking is how to get a leading zero in front of partial numbers as well, without adding three extra characters (a decimal and two zeroes) to all of the whole numbers.
bttrflii is offline   Reply With Quote
Old 05-15-2017, 08:50 PM   #6
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,782
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by bttrflii View Post
I can't quite figure out what you're trying to say. I *DO* want the leading zero, and I currently get a leading zero when the series number is a whole number. What I'm asking is how to get a leading zero in front of partial numbers as well, without adding three extra characters (a decimal and two zeroes) to all of the whole numbers.
sorry
5.2 means 5 places total 2 digits dot 2 digits
if you need 3 digits to the left: 6.2
if you need 3 digits to the right: 6.3

BTW I use {series_index:0>5.2f|| - }{title} on my K4

(and I discovered the hard way )
-{series_index:0>5.2f|| - }{title} causes a reverse sort
theducks is offline   Reply With Quote
Old 05-16-2017, 03:27 AM   #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: 11,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by bttrflii View Post
I can't quite figure out what you're trying to say. I *DO* want the leading zero, and I currently get a leading zero when the series number is a whole number. What I'm asking is how to get a leading zero in front of partial numbers as well, without adding three extra characters (a decimal and two zeroes) to all of the whole numbers.
It is possible to do what you want, but it requires making a custom column "Made from other columns" to compute the value.

Make the column and use the following as the template:
Code:
program:
	si = field('series_index');
	format = contains(si, '\.', '{0:06.2f}',  '{0:03d}');
	format_number(si, format)
Assuming the lookup name for this new column is #myseries_index, then use {#myseries_index} in the plugboard where you currently use series_index.
chaley is offline   Reply With Quote
Old 05-16-2017, 12:10 PM   #8
bttrflii
Junior Member
bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.
 
Posts: 9
Karma: 348
Join Date: May 2017
Device: Kindle Voyage
Quote:
Originally Posted by chaley View Post
It is possible to do what you want, but it requires making a custom column "Made from other columns" to compute the value.
I'm quite comfortable with custom columns, and your solution is just what I needed. :) I changed the "6.2f" and "3d" to "5.2f" and "2d" respectively since I never have series that make it to 100, but with that minor tweak it's doing exactly what I wanted, and I now have sortable series information in book titles that are sent to my Kindle, and it's done without clutter for those series without decimal places.

Thank you SO MUCH, chaley!!!
bttrflii is offline   Reply With Quote
Old 05-16-2017, 12:25 PM   #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,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by bttrflii View Post
I'm quite comfortable with custom columns, and your solution is just what I needed. I changed the "6.2f" and "3d" to "5.2f" and "2d" respectively since I never have series that make it to 100, but with that minor tweak it's doing exactly what I wanted, and I now have sortable series information in book titles that are sent to my Kindle, and it's done without clutter for those series without decimal places.

Thank you SO MUCH, chaley!!!
You are welcome.

A note, because I should write this somewhere ...

While working on other calibre stuff today I made a change to the format_date function. The change will appear in calibre V3. Up to now the format_number template had to be enclosed in { } characters, meaning that format_number couldn't be used in Template Program Mode because the TPM template evaluator can't handle sub-templates. That is why I said you needed to use a General Program Mode template.

The change is that if a format template does not contain a { character then it is now assumed to be a number format specification and is treated accordingly. This means that starting with calibre V3, the following will work, eliminating the need for the extra column.
Code:
{series_index:'format_number($, contains($, '\.', '06.2f',  '03d'))'}
Of course, current format_number templates will continue to work.
chaley is offline   Reply With Quote
Old 05-17-2017, 03:11 PM   #10
bttrflii
Junior Member
bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.bttrflii has a complete set of Star Wars action figures.
 
Posts: 9
Karma: 348
Join Date: May 2017
Device: Kindle Voyage
Quote:
Originally Posted by chaley View Post
[...]This means that starting with calibre V3, the following will work, eliminating the need for the extra column.[...]
That is awesome news! I'm sure others who'd hoped to have more control will appreciate this as much as I do, and I'll be sure to simplify my plugboard once I have calibre v3 installed. :) Thank you once more.
bttrflii is offline   Reply With Quote
Old 06-02-2017, 12:27 AM   #11
stuckinoh08
Junior Member
stuckinoh08 began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2012
Device: Kindle Paperwhite
So I am looking to do what the OP and sort series correctly with decimals. Currently I am using the following plugboard:

Code:
program:no_decimal = template('{series}{series_index:0>2s| | - }{title}');has_decimal = template('{series}{series_index:0>4.1f| | - }{title}');contains(field('series_index'),'\.',has_decimal,no_decimal)
Now, for all intents and purposes this works, except for one small caviat... When sorting a series of decimals, it sorts the whole number last. What I mean by this is this:

Series_Name 01 - Title
Series_Name 02.1 - Title
Series_Name 02.2 - Title
Series_Name 02 - Title
Series_Name 03 - Title

Now this isn't a huge issue, at least they a grouped together, and not 10 books apart, but it is a minor annoyance. I thought I would give Post #7's solution a try and unfortunately, it still sorts in the same manor.

Any advice?
stuckinoh08 is offline   Reply With Quote
Old 06-02-2017, 01:39 AM   #12
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,782
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by stuckinoh08 View Post
So I am looking to do what the OP and sort series correctly with decimals. Currently I am using the following plugboard:

Code:
program:no_decimal = template('{series}{series_index:0>2s| | - }{title}');has_decimal = template('{series}{series_index:0>4.1f| | - }{title}');contains(field('series_index'),'\.',has_decimal,no_decimal)
Now, for all intents and purposes this works, except for one small caviat... When sorting a series of decimals, it sorts the whole number last. What I mean by this is this:

Series_Name 01 - Title
Series_Name 02.1 - Title
Series_Name 02.2 - Title
Series_Name 02 - Title
Series_Name 03 - Title

Now this isn't a huge issue, at least they a grouped together, and not 10 books apart, but it is a minor annoyance. I thought I would give Post #7's solution a try and unfortunately, it still sorts in the same manor.

Any advice?
This is on the device?
ASCII sort rules usually prevail The shorter string version ( without the .# )should be first

I know (the hard way ) the Kindle treats a - before a number as a minus, so you get a descending order -5, -4,-3,-2..
theducks is offline   Reply With Quote
Old 06-03-2017, 12:21 AM   #13
stuckinoh08
Junior Member
stuckinoh08 began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Aug 2012
Device: Kindle Paperwhite
Quote:
Originally Posted by theducks View Post
This is on the device?
ASCII sort rules usually prevail The shorter string version ( without the .# )should be first

I know (the hard way ) the Kindle treats a - before a number as a minus, so you get a descending order -5, -4,-3,-2..
More info:

This issue is on the device (Paperwhite). If I plug the same template into a custom column, the sorting is done correctly. In regards to your comment about '-' preceding a number, that makes sense. However the '-', in this case, comes after the number so it should have no such effect. Would you suggest swapping out for a ':' to be safe? For what it's worth, when I used #7's fix, I used ':' and ended up with the same issue.

I considered the possibility that the error arises from the fact that the whole number values aren't followed by '.0'. I can manually test this, but seems odd.

Thoughts?
stuckinoh08 is offline   Reply With Quote
Old 06-03-2017, 10:37 AM   #14
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,782
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by stuckinoh08 View Post
More info:

This issue is on the device (Paperwhite). If I plug the same template into a custom column, the sorting is done correctly. In regards to your comment about '-' preceding a number, that makes sense. However the '-', in this case, comes after the number so it should have no such effect. Would you suggest swapping out for a ':' to be safe? For what it's worth, when I used #7's fix, I used ':' and ended up with the same issue.

I considered the possibility that the error arises from the fact that the whole number values aren't followed by '.0'. I can manually test this, but seems odd.

Thoughts?
I use "Collections" for my Series name, and place the series_index before the Title. using the plugboard. (including the series was just too long for my K4NT screen)
Code:
{series_index:0>5.2f|| - }{title}
10.00 - Title
Not optimal, but it fits on the screen
theducks is offline   Reply With Quote
Old 01-18-2020, 09:20 PM   #15
wildfire070
Member
wildfire070 began at the beginning.
 
Posts: 23
Karma: 10
Join Date: May 2012
Device: Kindle Oasis, Scribe, Paperwhite // Boox Palma
Quote:
Originally Posted by chaley View Post
It is possible to do what you want, but it requires making a custom column "Made from other columns" to compute the value.

Make the column and use the following as the template:
Code:
program:
	si = field('series_index');
	format = contains(si, '\.', '{0:06.2f}',  '{0:03d}');
	format_number(si, format)
Assuming the lookup name for this new column is #myseries_index, then use {#myseries_index} in the plugboard where you currently use series_index.
Can somebody walk me through how to implement this? I'm new to customizing Calibre and not sure where to start. Thanks!
wildfire070 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with series numbering plugboard Aliarides Calibre 40 12-30-2015 03:35 PM
Need Help with PW2 Metadata Plugboard and author sort PLUS series name drakebelisarius Amazon Kindle 3 02-26-2014 07:12 PM
Metadata Plugboard for Series Number Reformatting Victorious56 Library Management 4 05-08-2013 05:09 AM
Plugboard "Metadata: Show series [series index] - title as title (Kindle)" Deep Cover Library Management 6 11-30-2012 05:17 PM
Metadata Plugboard - First Char of each word in Series MikeP1212 Calibre 2 10-14-2010 06:14 PM


All times are GMT -4. The time now is 04:25 PM.


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