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 04-21-2017, 04:41 PM   #1
sekhemty
Member
sekhemty began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Feb 2017
Device: Kobo Glo
How to set the number of decimals in a custom column

I have setup a column to evaluate the approximate time required to read a given book, it is a column generated from other columns, and it is based on the word count.

This is what I have done right now:

{#hours:'divide(field('#words'), 250)'}

it works fine, except that I'd like to remove or set a limited number of decimals; having this column say that I need 15 hours makes sense, I don't really need to know that it really is 15.632643
sekhemty is offline   Reply With Quote
Old 04-21-2017, 06:40 PM   #2
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 22,034
Karma: 30277960
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by sekhemty View Post
I have setup a column to evaluate the approximate time required to read a given book, it is a column generated from other columns, and it is based on the word count.

This is what I have done right now:

{#hours:'divide(field('#words'), 250)'}

it works fine, except that I'd like to remove or set a limited number of decimals; having this column say that I need 15 hours makes sense, I don't really need to know that it really is 15.632643
Assuming #hours is a floating point number, try setting the format in the column definition to something suitable - e.g. {:+.2f}.

Useful link ==>> Python String Format Cookbook

BR

Last edited by BetterRed; 04-21-2017 at 07:35 PM.
BetterRed is offline   Reply With Quote
Advert
Old 04-22-2017, 07:31 AM   #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: 12,526
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Use something like
Code:
program: format_number(divide(raw_field('#words'), 250), '{:0.2f}')
with the appropriate changes for your variables and the number of decimals you want. You need to use raw_field if #words has a template that converts it into a string.
chaley is offline   Reply With Quote
Old 04-28-2017, 10:06 AM   #4
sekhemty
Member
sekhemty began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Feb 2017
Device: Kobo Glo
Thank you for the suggestions!
sekhemty is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Column for Folder Name AND Number?? kksdragons Library Management 9 08-23-2016 11:05 AM
Set Custom Column from identify.py ahisham Development 6 02-05-2015 10:53 AM
Custom column to display number of chapters? crackshot91 Library Management 10 09-08-2012 05:56 PM
Automatically set custom column when fetching news bork Library Management 1 04-14-2012 04:20 AM
Using OnDevice to set the value of a custom column WendyR14 Library Management 3 10-23-2011 09:03 PM


All times are GMT -4. The time now is 08:14 AM.


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