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 Today, 04:31 AM   #1021
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,120
Karma: 6426808
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by Montana Harper View Post
I realize this is probably a really niche thing, but is there any way to search a notes field (e.g., notes attached to an author) for specific text? I want to build a custom column that shows me a check mark if particular text is included in an author note.
I'd be interested in that, as well.

Currently the way I see to do it is using the Notes Browser with its FTS-like search syntax, like this:

Click image for larger version

Name:	MWSnap 2024-09-12, 05_02_49.png
Views:	14
Size:	58.1 KB
ID:	210786

In that example I've searched for authors born in 9/11.

Default shortcut is Ctrl + Shift + N. However I can't tell how to bring all results from that search into "main Calibre", so that I could bulk add the "Born in 9/11" tag, for instance.
Comfy.n is online now   Reply With Quote
Old Today, 06:49 AM   #1022
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,920
Karma: 7208979
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Montana Harper View Post
I realize this is probably a really niche thing, but is there any way to search a notes field (e.g., notes attached to an author) for specific text? I want to build a custom column that shows me a check mark if particular text is included in an author note.

I have a number of custom columns built from other columns that do something similar, but since the notes aren't fields with lookup names, I'm not even sure if it's possible to do what I want. Currently I'm using a workaround that involves adding a specific tag to every book by an author whom I want to flag, but that's both time-consuming and easy to forget about when adding a new book, whereas if I can just make a single note for the author it would be so much easier.

TIA!
You can do this with the template function get_note().

You can search a note using a template like this one, suitably modified.
Code:
program:
	first_author = sublist($authors, 0, 1, '&');
	note = get_note('authors', first_author, '1');
	if 'something' in note then
		ans = 'Yes'
	else
		ans = 'No'
	fi;
	ans
Notes on the template:
  • This uses the first author. You must decide what to do if there are multiple authors. For example, you might want to loop over all the authors checking if any have a note.
  • The first argument of the 'in' operator is a regular expression. Keep that in mind when deciding on what search you want to do.
  • Using the 'ans' variable isn't really necessary. You can instead use the return value of the 'if'. I use the variable to avoid problems if/when code is added after the if, just to be sure I am getting the return value I want.
  • IMPORTANT: While testing this I found a bug in the get_note() function. The 'plain_text' option doesn't work. I have submitted a fix to Kovid. I will post here when the fix is in calibre source. In the meantime use HTML instead of plain text (the third parameter to get_note() is ''). It will be significantly slower but it should work as long as what you are looking for doesn't resemble an HTML tag too closely.

Depending on what you want to do, there are two ways to proceed.
  1. You just want a column with a checkmark
    • Create a composite column using the above template, with "show checkmarks" True.
  2. You want a column icon
    • Create an advanced rule using the template, but return the image name instead of 'Yes' or 'No'
    or
    • Create a composite column using the above template Use this column in a column icon rule looking for the value 'Yes'. You might want to hide this column in the booklist and book details.
  3. You want both. Do the composite column in option 1 then use that column in the second choice for the column icon in option 2.

Last edited by chaley; Today at 07:25 AM.
chaley is offline   Reply With Quote
Old Today, 07:16 AM   #1023
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,120
Karma: 6426808
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by chaley View Post
You can search a note using a template like this one, suitably modified.
Is it possible, currently, to run that on the Advanced Search template field?

I get "EXCEPTION: string indices must be integers, not 'str'" in the Template Editor.

I'm trying with: Comparison type - Text, and pasting the code in field Template, while leaving the field Template Value empty.
Comfy.n is online now   Reply With Quote
Old Today, 07:24 AM   #1024
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,920
Karma: 7208979
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Comfy.n View Post
Is it possible, currently, to run that on the Advanced Search template field?

I get "EXCEPTION: string indices must be integers, not 'str'" in the Template Editor.

I'm trying with: Comparison type - Text, and pasting the code in field Template, while leaving the field Template Value empty.
Yes, but the IMPORTANT part of my post is relevant. Until the fix is in calibre source you must use
Code:
get_note('authors', first_author, '')
chaley is offline   Reply With Quote
Old Today, 07:54 AM   #1025
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,920
Karma: 7208979
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by chaley View Post
IMPORTANT: While testing this I found a bug in the get_note() function. The 'plain_text' option doesn't work. I have submitted a fix to Kovid. I will post here when the fix is in calibre source. In the meantime use HTML instead of plain text (the third parameter to get_note() is ''). It will be significantly slower but it should work as long as what you are looking for doesn't resemble an HTML tag too closely.
The fix is now in calibre source. If you run from source you can now use
Code:
get_note('authors', first_author, 1)
and not get the exception. If you don't run from source you must wait until the next calibre preview/release.
chaley is offline   Reply With Quote
Old Today, 08:29 AM   #1026
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,120
Karma: 6426808
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by chaley View Post
The fix is now in calibre source.
It works in the template editor, showing "Yes" for a given value when a book whose author's notes contain the string is currently selected.

However when I paste the template in the search bar, it returns no results, so I must be doing something the wrong way

Last edited by Comfy.n; Today at 08:32 AM.
Comfy.n is online now   Reply With Quote
Old Today, 08:42 AM   #1027
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,920
Karma: 7208979
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Comfy.n View Post
It works in the template editor, showing "Yes" for a given value when a book whose author's notes contain the string is currently selected.

However when I paste the template in the search bar, it returns no results, so I must be doing something the wrong way
Works for me when using the advanced search template search builder running from latest source (with the fix). This example finds any note containing the letter 'a'.

Template:
Code:
program:
	first_author = sublist($authors, 0, 1, '&');
	note = get_note('authors', first_author, '1');
	if 'a' in note then
		ans = 'Yes'
	else
		ans = ''
	fi;
	ans
The template search dialog:
Click image for larger version

Name:	Clipboard01.jpg
Views:	4
Size:	67.6 KB
ID:	210791

Note that the template search generated by the dialog contains more than just the template.

Last edited by chaley; Today at 08:44 AM.
chaley is offline   Reply With Quote
Old Today, 09:45 AM   #1028
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,120
Karma: 6426808
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by chaley View Post
Create a composite column using the above template, with "show checkmarks" True.
That works fine,

Click image for larger version

Name:	MWSnap 2024-09-12, 10_21_14.png
Views:	1
Size:	4.1 KB
ID:	210793

Now I'm trying to fix my advanced search issue, hopefully I can come up later with more detailed info. I think my notes database has grown too much lately, and when I do the search as indicated in your screenshot for Advanced Search, Calibre enters some seemingly infinite database lookup.

This has happened other times and I solved it by recreating my Bio column. (deleting it, then re-adding). Today this didn't seem to solve the issue. Process Monitor shows this:

Click image for larger version

Name:	MWSnap 2024-09-12, 10_43_46.png
Views:	4
Size:	104.4 KB
ID:	210792
Comfy.n is online now   Reply With Quote
Reply

Tags
custom column, tag, tags


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
custom column i need a little help shinken Calibre 3 09-15-2010 03:41 AM
Using Custom Metadata in Save Template EJvdH Calibre 1 07-02-2010 06:06 AM
Accessories Decalgirl Kindle 2 custom skin template srmalloy Amazon Kindle 6 04-09-2010 09:55 PM
Donations for Custom Recipes ddavtian Calibre 5 01-23-2010 04:54 PM
Help understanding custom recipes andersent Calibre 0 12-17-2009 02:37 PM


All times are GMT -4. The time now is 10:32 AM.


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