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 11-15-2023, 10:40 AM   #1
crnirg
Connoisseur
crnirg began at the beginning.
 
Posts: 60
Karma: 10
Join Date: Nov 2010
Location: Niš, Srbija
Device: TCL Nxtpaper 11, Kindle PW 2024
Size COMMENTS column ?

How can I make my column in which the length (size) of the COMMENTS column will be in characters or maybe just whether it is more or less than say 50?
crnirg is offline   Reply With Quote
Old 11-15-2023, 12:13 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 crnirg View Post
How can I make my column in which the length (size) of the COMMENTS column will be in characters or maybe just whether it is more or less than say 50?
Make a "Column built from other columns" with the heading and lookup name whatever you want.

To show the length, set the template to this Single Function Mode template and set the column's Sort/search type to "Number".
Code:
{comments:strlen()}
To make it say "Yes" if the length is greater than or equal to 50, otherwise "No" use this Template Program Mode template
Code:
{comments:'cmp(strlen($), 50, 'No', 'Yes', 'Yes')'}
or this General Program Mode template
Code:
program:
	if strlen($comments) >=# 50 then 'Yes' else 'No' fi
or this Python Template Mode template
Code:
python:
def evaluate(book, context):
	comments = book.get('comments')
	return 'Yes' if comments and len(book.get('comments')) >= 50 else 'No'
chaley is offline   Reply With Quote
Advert
Old 11-15-2023, 01:08 PM   #3
crnirg
Connoisseur
crnirg began at the beginning.
 
Posts: 60
Karma: 10
Join Date: Nov 2010
Location: Niš, Srbija
Device: TCL Nxtpaper 11, Kindle PW 2024
Thanks for the answer - I tried it and for an empty comment it shows exactly 0, but already for the test 0123456789 it shows 29.
And for larger comments, it makes mistakes - the bigger the comment, the bigger the error - let's say from 20-60 for lengths of 10-2300 characters.
I'm sure it's something small, but it's a joke.
crnirg is offline   Reply With Quote
Old 11-15-2023, 01:13 PM   #4
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 crnirg View Post
Thanks for the answer - I tried it and for an empty comment it shows exactly 0, but already for the test 0123456789 it shows 29.
And for larger comments, it makes mistakes - the bigger the comment, the bigger the error - let's say from 20-60 for lengths of 10-2300 characters.
I'm sure it's something small, but it's a joke.
Comments are in HTML. Those characters count.
chaley is offline   Reply With Quote
Old 11-15-2023, 01:17 PM   #5
crnirg
Connoisseur
crnirg began at the beginning.
 
Posts: 60
Karma: 10
Join Date: Nov 2010
Location: Niš, Srbija
Device: TCL Nxtpaper 11, Kindle PW 2024
Here is an example:


<div>
<p>Prevod: Živković Mirjana; Naslov originala: Anderson Poul THREE HEARTS AND THREE LIONS, 1961.</p>
<p>Prevod: Živković Mirjana; Naslov originala: Anderson Poul THREE HEARTS AND THREE LIONS, 1961.</p></div>

online says 211 my Calibre 188 .

That I don't bother you too much?
crnirg is offline   Reply With Quote
Advert
Old 11-15-2023, 02:52 PM   #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: 12,443
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Using this text:
Code:
<div>
<p>Prevod: Živković Mirjana; Naslov originala: Anderson Poul THREE HEARTS AND THREE LIONS, 1961.</p>
<p>Prevod: Živković Mirjana; Naslov originala: Anderson Poul THREE HEARTS AND THREE LIONS, 1961.</p></div>
and using the template {comments:strlen()}, I get 213 characters.

If I manually count the displayed characters I also get 213, the same as the template. Don't forget that the end of line is a character.

Loading that text into Notepad++, a text editor, I get 217 characters. The difference between Notepad++ and the template is that Notepad is counting the components (bytes) of composed characters, for example Ž and ć, as two characters (bytes). There are 4 such characters in the string, making the length 4 longer: 217 instead of 213.

I have no idea where the 188 comes from. Nor do I know where the "online tool" gets 211.

In any event, the output of the template is the best count your going to get from calibre.
chaley is offline   Reply With Quote
Old 11-15-2023, 04:47 PM   #7
crnirg
Connoisseur
crnirg began at the beginning.
 
Posts: 60
Karma: 10
Join Date: Nov 2010
Location: Niš, Srbija
Device: TCL Nxtpaper 11, Kindle PW 2024
Tried it and just like you say - it's probably because of the HMTL tags - in any case, thanks a lot for the answer.
crnirg is offline   Reply With Quote
Old 11-17-2023, 12:36 PM   #8
crnirg
Connoisseur
crnirg began at the beginning.
 
Posts: 60
Karma: 10
Join Date: Nov 2010
Location: Niš, Srbija
Device: TCL Nxtpaper 11, Kindle PW 2024
'7' seems to give me a lot of possibilities that I wanted - learning regex will remain a wish, so far as it goes
crnirg is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to show comments in a column? halloleo Library Management 10 11-16-2023 03:18 AM
Custom Column made from Comments slantybard Library Management 5 01-31-2022 01:07 AM
Show comments in column nhgbslik Library Management 3 09-18-2019 04:52 PM
Comments column Tanjamuse Calibre 11 04-17-2016 05:18 AM
Bulk Edit Comments column Jade Aislin Library Management 0 10-27-2011 03:18 AM


All times are GMT -4. The time now is 05:09 AM.


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