Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 07-25-2020, 06:26 PM   #1
Mansoul
Member
Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.
 
Posts: 19
Karma: 34258
Join Date: Jul 2020
Device: Kobo Libra H2O
Custom Column - How Long to Read

I've got Calibre showing page and word counts, I'd like to have a custom column that reads the word count, divides by reading speed, then divides by 60 to produce a value in hours and minutes.

I've looked through the template language doc but I'm lost, can anyone please help me out?
Mansoul is offline   Reply With Quote
Old 07-25-2020, 08:18 PM   #2
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 74,196
Karma: 129333564
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Mansoul View Post
I've got Calibre showing page and word counts, I'd like to have a custom column that reads the word count, divides by reading speed, then divides by 60 to produce a value in hours and minutes.

I've looked through the template language doc but I'm lost, can anyone please help me out?
Try reading a few books and time yourself while reading them you can figure out the math from there.
JSWolf is online now   Reply With Quote
Advert
Old 07-26-2020, 12:31 AM   #3
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,906
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Something like the following is what you want:

Code:
program:
format_number(divide(divide(raw_field('#words'),1000),60), '{0:5,.2f}')
In that, the 1000 is the reading speed. You can do it with one divide if you calculate the reading speed in words per hour rather than words per minute.

The formatting will give the number with two decimal points.
davidfor is offline   Reply With Quote
Old 07-28-2020, 03:57 PM   #4
Mansoul
Member
Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.
 
Posts: 19
Karma: 34258
Join Date: Jul 2020
Device: Kobo Libra H2O
Thank you both, again.

I couldn't figure out where the code goes, tried custom columns and template functions but the code itself appears in the column.

No bother, I can use word the count to give me an idea.
Mansoul is offline   Reply With Quote
Old 07-29-2020, 05:46 AM   #5
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,906
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
It is the template for a custom column of type "Column built from other columns". Put all of the code that I posted into that. This include the "program:".
davidfor is offline   Reply With Quote
Advert
Old 07-29-2020, 06:05 AM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 74,196
Karma: 129333564
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
If you use the Kobo time count, you can figure out your reading speed and use that to get a more accurate result. I suggest at least 5 times.
JSWolf is online now   Reply With Quote
Old 07-29-2020, 06:19 AM   #7
Loosheesh
Wizard
Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.
 
Loosheesh's Avatar
 
Posts: 1,674
Karma: 3111989
Join Date: Dec 2010
Location: Jianghu
Device: PW1, PW5, iPhone SE 2016, iPhone 13 Pro, iPad Pro 9.7, iPad Pro 2021
Quote:
Originally Posted by davidfor View Post
It is the template for a custom column of type "Column built from other columns". Put all of the code that I posted into that. This include the "program:".
I'm also interested in creating a custom column like this and I'd like to know what to put in the other fields (function and argument):

Loosheesh is offline   Reply With Quote
Old 07-29-2020, 06:49 AM   #8
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,906
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by Loosheesh View Post
I'm also interested in creating a custom column like this and I'd like to know what to put in the other fields (function and argument):

That is the wrong place. From there, you can create a function to be used elsewhere. If you are trying to do what @Mansoul has asked, this would be overkill.

The instructions for adding custom column with a template are in Techniques to use plugboards, custom columns and templates.
davidfor is offline   Reply With Quote
Old 07-29-2020, 07:34 PM   #9
kcar181
Member
kcar181 began at the beginning.
 
kcar181's Avatar
 
Posts: 15
Karma: 10
Join Date: Jul 2020
Device: none
Quote:
Originally Posted by davidfor View Post
Something like the following is what you want:

Code:
program:
format_number(divide(divide(raw_field('#words'),1000),60), '{0:5,.2f}')
In that, the 1000 is the reading speed. You can do it with one divide if you calculate the reading speed in words per hour rather than words per minute.

The formatting will give the number with two decimal points.
This is really cool thanks for this. I'm getting numbers like 2.29 would that be 2 hours 29 min?

EDIT: Now I see numbers like 1.86 so im guessing not hours/minutes. Anyway to convert?

Last edited by kcar181; 07-29-2020 at 07:50 PM.
kcar181 is offline   Reply With Quote
Old 07-29-2020, 07:55 PM   #10
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,677
Karma: 61664305
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by kcar181 View Post
This is really cool thanks for this. I'm getting numbers like 2.29 would that be 2 hours 29 min?

EDIT: Now I see numbers like 1.86 so im guessing not hours/minutes. Anyway to convert?
Multiply by 60 to get the number of minutes.

For 2.29 hours that's ~137 minutes.

Divide that by sixty again using whole numbers and the remainder is 17 minutes.

You end up with 2:17.

Last edited by ownedbycats; 07-29-2020 at 08:04 PM.
ownedbycats is offline   Reply With Quote
Old 07-29-2020, 08:08 PM   #11
kcar181
Member
kcar181 began at the beginning.
 
kcar181's Avatar
 
Posts: 15
Karma: 10
Join Date: Jul 2020
Device: none
Ok so if id like just minutes im guessing this would do the trick

Code:
program:
format_number(multiply(divide(divide(raw_field('#chars'),310),60),60), '{0:5,.2f}')
And the first code was closer to hours so 1.86 would translate to 2 hours 26 minutes?

EDIT: Ok learning something new. So I think 1.86 would be a decimal hour so 1 hour and 86/100 of an hour.

Last edited by kcar181; 07-29-2020 at 08:18 PM.
kcar181 is offline   Reply With Quote
Old 07-29-2020, 08:40 PM   #12
Loosheesh
Wizard
Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.Loosheesh ought to be getting tired of karma fortunes by now.
 
Loosheesh's Avatar
 
Posts: 1,674
Karma: 3111989
Join Date: Dec 2010
Location: Jianghu
Device: PW1, PW5, iPhone SE 2016, iPhone 13 Pro, iPad Pro 9.7, iPad Pro 2021
Quote:
Originally Posted by davidfor View Post
That is the wrong place. From there, you can create a function to be used elsewhere. If you are trying to do what @Mansoul has asked, this would be overkill.

The instructions for adding custom column with a template are in Techniques to use plugboards, custom columns and templates.
I initially put the code in the right place but left out "program:" (though you specifically said to add it! ). When it didn't work at first, I got to thinking I should've gone to the Template functions section instead

Anyway, it works now
Loosheesh is offline   Reply With Quote
Old 07-30-2020, 06:47 AM   #13
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,748
Karma: 7029855
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Multiply by 60 to get the number of minutes.

For 2.29 hours that's ~137 minutes.

Divide that by sixty again using whole numbers and the remainder is 17 minutes.

You end up with 2:17.
Unfortunately you currently can't do that calculation in the template language. All the arithmetic is floating point.

I am going to add some more math functions: floor(x), ceiling(x), fractional_part(x), round(x), and mod(x, y). Using these (when they are released), you will be able to compute hours:minutes from fractional hours using something like this template.
Code:
program:
# total_hours should be a field reference
	fractional_hours = 3.6982;
# Compute the number of hours in total minutes as an integer
	display_hours = floor(fractional_hours );
# Compute the number of minutes left over after display_hours
	display_mins = round(multiply(fractional_part(fractional_hours ), 60));
# Format the results as h:mm
	strcat(display_hours, ':', format_number(display_mins, '02d'))
This template produces the result "3:42"
chaley is offline   Reply With Quote
Old 07-30-2020, 08:58 AM   #14
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,906
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
And here was me thinking of doing:

Code:
program:
minutes = divide(raw_field('#words'),310);
hours = divide(minutes, 60);
hours = list_item(hours,0,'.');
minutes = subtract(minutes, multiply(hours,60));
minutes = format_number(minutes, '02,.0f');
strcat(hours,':',minutes)
Ugly, but it seems to work. I'd probably combine a couple of lines, but, separating them helps the debugging.

But, I've wanted some of your new functions before. So, I'm happy to see them.
davidfor is offline   Reply With Quote
Old 07-30-2020, 09:12 AM   #15
Mansoul
Member
Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.Mansoul is out to avenge the death of his or her father, Domingo Montoya.
 
Posts: 19
Karma: 34258
Join Date: Jul 2020
Device: Kobo Libra H2O
I missed out the 'program:' in mine as well, got it working now.

Really appreciate everyone's input!
Mansoul is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Browser Viewer: Long-text Custom Column nqk Server 8 08-05-2018 08:25 AM
Custom column long text toolbar MerlinMama Calibre 2 03-01-2017 01:14 PM
Creating Custom Column for Read and Date Read library addict Calibre Companion 11 03-22-2014 05:33 AM
Custom yes/no column built from long text column Philantrop Library Management 7 03-23-2013 07:44 PM
No search/replace on custom long text column? CWatkinsNash Library Management 2 06-20-2011 05:57 PM


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


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