Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 09-29-2011, 05:22 AM   #1
iomari
Zealot
iomari doesn't litteriomari doesn't litter
 
Posts: 146
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
size column

Greetings,
It appears that the size column does not total all the formats of a particular entry. How can I accomplish this?
iomari is offline   Reply With Quote
Old 09-29-2011, 09:23 AM   #2
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,809
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 iomari View Post
Greetings,
It appears that the size column does not total all the formats of a particular entry. How can I accomplish this?
IIRC The size shows the Biggest one (single format) only.

The QC plugin can recalculate the size column values (if you have modified that format after importing/or conversion).
IMHO Total is only useful for Libraries. I send a specific, single format, to my device. Not all formats (which it does poorly with many of those).
theducks is offline   Reply With Quote
Advert
Old 09-29-2011, 12:00 PM   #3
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
You can get a list of the formats with their sizes using a composite custom column (column built from other columns) with the template {:'formats_sizes()'}

You can get the sum of the sizes in one of two ways.
  • The most efficient would be to write a custom template function (preferences, advanced, template functions) that sums the values returned by format_sizes. The function would be something like
    Code:
    Function name: mySum
    Arg count: 1
    Program code:
    def evaluate(self, formatter, kwargs, mi, locals, x):
    	r = 0
    	if x.strip():
    		for p in x.split(','):
    			v = p.split(':')[1]
    			r += long(v)
    	return unicode(r)
    Then you would use this function in a composite column with the template
    Code:
    {:'mySum(formats_sizes())'}
    or perhaps
    Code:
    {:'human_readable(mySum(formats_sizes()))'}
  • Easier if you are not a python programmer but definitely more of a bother to do would be to make a composite custom column containing a variant of the following template:
    Code:
    program: 
    	fs = formats_sizes();
    	v = select(fs, 'PRC');
    	v = add(v, select(fs, 'EPUB'));
    	v = add(v, select(fs, 'MOBI'));
    	v = add(v, select(fs, 'TXT'));
    	v = add(v, select(fs, 'LIT'));
    	v = format_number(v, '{0:5.0f}');
    	human_readable(v)
    Duplicate the v = add... line as many times as necessary to include all the formats of interest.
chaley is offline   Reply With Quote
Old 09-30-2011, 05:33 AM   #4
iomari
Zealot
iomari doesn't litteriomari doesn't litter
 
Posts: 146
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
Thanks guys
iomari is offline   Reply With Quote
Old 09-30-2011, 06:14 AM   #5
iomari
Zealot
iomari doesn't litteriomari doesn't litter
 
Posts: 146
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
chaley your snippet worked perfect for me. Is it possible to format the {:'formats_sizes()'} function with human readable? I tried {:'human_readable(formats_sizes())'} but it returned an error.
iomari is offline   Reply With Quote
Advert
Old 09-30-2011, 06:34 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 iomari View Post
Is it possible to format the {:'formats_sizes()'} function with human readable? I tried {:'human_readable(formats_sizes())'} but it returned an error.
No. Human_readable requires a single number.

You can, of course, do this in a user-defined formatter function. It would look something like
Code:
Function name: mySizes
Arg count: 1
Program code:
def evaluate(self, formatter, kwargs, mi, locals, x):
	from calibre import human_readable
	r = []
	if x.strip():
		for p in x.split(','):
			v = p.split(':')
			r.append(v[0] + ': ' + human_readable(long(v[1])))
	return ', '.join(r)
and would be used something like
Code:
{:'mySizes(formats_sizes())'}
chaley is offline   Reply With Quote
Old 09-30-2011, 07:00 AM   #7
iomari
Zealot
iomari doesn't litteriomari doesn't litter
 
Posts: 146
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
cool, thanks
iomari is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get {size} data in a User Column? CCarrot Calibre 16 06-26-2012 11:39 AM
Q: multi-column PDF to single column mobi format converstion auburn1975 Calibre 7 01-28-2012 06:11 PM
Cover Size Column? transmitthis Library Management 5 06-19-2011 06:27 AM
Refresh size column Perkin Calibre 5 09-10-2010 11:31 AM
Purpose of Size column? itimpi Calibre 6 06-16-2009 08:44 PM


All times are GMT -4. The time now is 11:24 PM.


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