Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 12-01-2010, 10:58 PM   #1
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
Feature request: How many authors?

Is there any way to count the number of items in a comma-separated field, such as the list of authors?

Basically, I'm after creating a custom column which contains a count of the number of authors for each book (to make life easier when it comes to manually cross-linking books into different collections on the kindle, since you ask). But for the life of me I can't see an {authors_count} or (authors:count()} or similar.
mornington is offline   Reply With Quote
Old 12-02-2010, 01:16 AM   #2
itimpi
Wizard
itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.
 
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
First time I can ever remember any asking about such a feature

You should raise the feature request by raising a ticket in the Calibre tracking system as forum messages for feature requests can get lost (and then forgotten) amongst the volume of messages posted.
itimpi is offline   Reply With Quote
Advert
Old 12-02-2010, 07:57 AM   #3
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
Cheers. I've raised a ticket here:

http://bugs.calibre-ebook.com/ticket/7769
mornington is offline   Reply With Quote
Old 12-02-2010, 08:29 AM   #4
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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Code submitted.

There is now a template function 'count'. It takes one argument, the character that separates the items in the list. Most lists use comma, but authors uses ampersand.

Examples:
tags: {tags:count(,)}
authors: {authors:count(&)}
a custom multiple field: {#mymult:count(,)}

As another example, imagine that you have a custom field #genre that you use for hierarchical tagging. This would be a text (non-multiple) field containing things like
Science:Biology:Plankton
Fiction:Mystery:Crime:Police
You can count these via
{#genre:count(:)}

Last edited by chaley; 12-02-2010 at 09:18 AM.
chaley is offline   Reply With Quote
Old 12-02-2010, 09:13 AM   #5
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
Wonderful. Thanks muchly for that - it'll come in very useful (especially the way you've implemented it).

Presumably this will show up in the next release?
mornington is offline   Reply With Quote
Advert
Old 12-02-2010, 09:18 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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by mornington View Post
Presumably this will show up in the next release?
Probably. Real answer depends on how much available 'review code' time Kovid has available.
chaley is offline   Reply With Quote
Old 12-02-2010, 11:32 AM   #7
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
I'm sure it'll show up sometime ;-)

And thanks again for writing this.
mornington is offline   Reply With Quote
Old 12-03-2010, 03:57 PM   #8
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
And I see it's appeared in release 0.7.32.

One small issue. though, is that the "number" produced by count() seems to be treated as text, rather than an integer, for sorting purposes meaning that "{authors:count(&)}" can't be sorted numerically.

This can be worked around by using a second custom column with "{#numauthors:0>2s}" but is there any way to have the whole thing done in a single field (i.e. so the output is "01","02,"03",etc) or to make the numbers in such a column be sorted as numbers, rather than as text?
mornington is offline   Reply With Quote
Old 12-03-2010, 06:55 PM   #9
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
Quote:
Originally Posted by mornington View Post
And I see it's appeared in release 0.7.32.

One small issue. though, is that the "number" produced by count() seems to be treated as text, rather than an integer, for sorting purposes meaning that "{authors:count(&)}" can't be sorted numerically.

This can be worked around by using a second custom column with "{#numauthors:0>2s}" but is there any way to have the whole thing done in a single field (i.e. so the output is "01","02,"03",etc) or to make the numbers in such a column be sorted as numbers, rather than as text?
As a more general principle, I suppose I'm asking if there's a way to tell calibre that a given custom column should be sorted as numerical rather than textual data.
mornington is offline   Reply With Quote
Old 12-04-2010, 04:05 AM   #10
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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by mornington View Post
And I see it's appeared in release 0.7.32.

One small issue. though, is that the "number" produced by count() seems to be treated as text, rather than an integer, for sorting purposes meaning that "{authors:count(&)}" can't be sorted numerically.

This can be worked around by using a second custom column with "{#numauthors:0>2s}" but is there any way to have the whole thing done in a single field (i.e. so the output is "01","02,"03",etc) or to make the numbers in such a column be sorted as numbers, rather than as text?
I assume you have created a composite custom column showing this value? If you want leading zeros, then that column's template should be
Code:
{authors:0>2s:count(&)}
Format specifications are applied after function specifications.

As for specifying the sort type, that won't work in your case. Composite columns are always strings.
chaley is offline   Reply With Quote
Old 12-04-2010, 05:19 AM   #11
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
Quote:
Originally Posted by chaley View Post
I assume you have created a composite custom column showing this value? If you want leading zeros, then that column's template should be
Code:
{authors:0>2s:count(&)}
Format specifications are applied after function specifications.

As for specifying the sort type, that won't work in your case. Composite columns are always strings.
That's what I was after - thanks a lot. I tried a couple of different syntax combinations (but not that one, obviously) but couldn't figure out one that did it.

Sorting-wise, it's fine sorting by string so long as the string is zero-filled ;-)
mornington is offline   Reply With Quote
Reply

Tags
count, feature request


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Feature request: oilwood Calibre 5 11-08-2010 02:59 PM
Feature Request Partzz Calibre 6 09-09-2010 01:11 PM
Feature Request? Sydney's Mom Calibre 6 07-22-2010 12:32 PM
Feature request mrmikel EPUBReader 4 11-20-2009 11:49 AM
Feature request AprilHare Calibre 0 11-22-2008 05:42 AM


All times are GMT -4. The time now is 01:46 PM.


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