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, 03:41 PM   #1
sekhemty
Member
sekhemty began at the beginning.
 
Posts: 15
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, 05: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: 20,572
Karma: 26954694
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 06:35 PM.
BetterRed is offline   Reply With Quote
Old 04-22-2017, 06: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: 11,742
Karma: 6997045
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, 09:06 AM   #4
sekhemty
Member
sekhemty began at the beginning.
 
Posts: 15
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 10:05 AM
Set Custom Column from identify.py ahisham Development 6 02-05-2015 09:53 AM
Custom column to display number of chapters? crackshot91 Library Management 10 09-08-2012 04:56 PM
Automatically set custom column when fetching news bork Library Management 1 04-14-2012 03:20 AM
Using OnDevice to set the value of a custom column WendyR14 Library Management 3 10-23-2011 08:03 PM


All times are GMT -4. The time now is 06:56 PM.


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