|
|
#1 |
|
Connoisseur
![]() Posts: 70
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?
|
|
|
|
|
|
#2 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
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()}
Code:
{comments:'cmp(strlen($), 50, 'No', 'Yes', 'Yes')'}
Code:
program: if strlen($comments) >=# 50 then 'Yes' else 'No' fi Code:
python:
def evaluate(book, context):
comments = book.get('comments')
return 'Yes' if comments and len(book.get('comments')) >= 50 else 'No'
|
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Connoisseur
![]() Posts: 70
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. |
|
|
|
|
|
#4 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525
Karma: 8065948
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
|
|
|
|
|
|
|
#5 |
|
Connoisseur
![]() Posts: 70
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? |
|
|
|
| Advert | |
|
|
|
|
#6 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525
Karma: 8065948
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> 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. |
|
|
|
|
|
#7 |
|
Connoisseur
![]() Posts: 70
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.
|
|
|
|
|
|
#8 |
|
Connoisseur
![]() Posts: 70
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
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to show comments in a column? | halloleo | Library Management | 10 | 11-16-2023 04:18 AM |
| Custom Column made from Comments | slantybard | Library Management | 5 | 01-31-2022 02:07 AM |
| Show comments in column | nhgbslik | Library Management | 3 | 09-18-2019 05:52 PM |
| Comments column | Tanjamuse | Calibre | 11 | 04-17-2016 06:18 AM |
| Bulk Edit Comments column | Jade Aislin | Library Management | 0 | 10-27-2011 04:18 AM |