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 07-01-2021, 05:36 PM   #1
Courge
Junior Member
Courge began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Jul 2021
Device: Kindle paperwhite
Format words count 1500 as 1.5k

Hello,

I created a custom column "Words" that I fill with the FanFicFare plugin (collecting the number of words from the fanfiction website). Is there a method to format the numbers in kilo? For example, 1500 as 1.5k or 34267 as 34.3k.

I noticed that python format can be used to format custom column but it does not allow python function which would be needed for what I want (see the page https://www.geeksforgeeks.org/python-numerize-library/).

Thank you!
Courge is offline   Reply With Quote
Old 07-01-2021, 06:24 PM   #2
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,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Courge View Post
Hello,

I created a custom column "Words" that I fill with the FanFicFare plugin (collecting the number of words from the fanfiction website). Is there a method to format the numbers in kilo? For example, 1500 as 1.5k or 34267 as 34.3k.

I noticed that python format can be used to format custom column but it does not allow python function which would be needed for what I want (see the page https://www.geeksforgeeks.org/python-numerize-library/).

Thank you!
You can't do what you want with the format option on the integer custom column. You can do what you want using a composite column (column built from other columns) with a template that computes what you want to see. You would hide the column filled in by FanFicFare and display the composite.

As for formatting the result in the composite, you have the option of using the human_readable() function or doing the arithmetic yourself.
chaley is offline   Reply With Quote
Advert
Old 07-01-2021, 06:43 PM   #3
Courge
Junior Member
Courge began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Jul 2021
Device: Kindle paperwhite
Quote:
Originally Posted by chaley View Post
You can do what you want using a composite column (column built from other columns) with a template that computes what you want to see. You would hide the column filled in by FanFicFare and display the composite.

As for formatting the result in the composite, you have the option of using the human_readable() function or doing the arithmetic yourself.
Thank you for your answer. I am begining with Calibre and I am not sure how to apply your suggestion. I created a composite column "formated_words" and in "Template" I entered :
Code:
human_readable(words)
It simply prints "human_readable(words)" in my new composite column (with "words" the lookup name of my previous column. Do you know what is wrong with my template or where I can find more information?

Thank you!

Last edited by Courge; 07-01-2021 at 06:45 PM.
Courge is offline   Reply With Quote
Old 07-01-2021, 06:47 PM   #4
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: 21,718
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@Courge - When referring to custom columns in a template etc you need to prefix the lookup_name with a hash - eg. #words

BR
BetterRed is online now   Reply With Quote
Old 07-01-2021, 06:55 PM   #5
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,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Courge View Post
Thank you for your answer. I am begining with Calibre and I am not sure how to apply your suggestion. I created a composite column "formated_words" and in "Template" I entered :
Code:
human_readable(words)
It simply prints "human_readable(words)" in my new composite column (with "words" the lookup name of my previous column. Do you know what is wrong with my template or where I can find more information?

Thank you!
First: as for where you can find more information, see The calibre template language.

My guess is that you want something like this Single Function Mode template
Code:
{#words:human_readable()}
If you want more complicated formatting then you will probably should use a General Program Mode template
chaley is offline   Reply With Quote
Advert
Old 07-01-2021, 07:43 PM   #6
Courge
Junior Member
Courge began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Jul 2021
Device: Kindle paperwhite
Thanks to both of you for your answers. I got what I want writing the following template:
Code:
program:
before = round($$#words/1000);
after = round(($$#words-(before*1000))/100)*0.1;
complete=before+after
I will add the "k" after the number in the plugboard when sending the files to the device.
Courge is offline   Reply With Quote
Old 07-01-2021, 11:52 PM   #7
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: 21,718
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
I initially interpreted your request as wanting 1024 words to be 1K words. I decided against asking why you'd wanna do that.

BR
BetterRed is online now   Reply With Quote
Old 07-02-2021, 12:05 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,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by BetterRed View Post
I initially interpreted your request as wanting 1024 words to be 1K words. I decided against asking why you'd wanna do that.
I'm generally against capital punishment, but for the person who thought, "Kilo=1000, 1024 is close enough", I'm willing to make an exception.
davidfor is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Count words in whole book franc Reading and Management 16 03-31-2021 05:35 PM
Page Count not appearing in ipad kindle - mobi format eloigorri Devices 9 06-17-2020 04:35 PM
Word Count/Unique Words thesn00ze Editor 7 04-18-2019 06:36 AM
1500 Words Per Hour: How To Write Faster, Better And More Easily crich70 Writers' Corner 6 06-11-2014 11:27 AM
How to dictionary with PDF format install in Kindle for look up words? douxiaobo Kindle Developer's Corner 4 04-01-2012 09:10 AM


All times are GMT -4. The time now is 10:39 PM.


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