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 03-22-2018, 06:55 AM   #1
Tatjana
Coffee Girl
Tatjana began at the beginning.
 
Tatjana's Avatar
 
Posts: 16
Karma: 10
Join Date: May 2014
Device: no money for such things
Question Custom Column with the length of the lengthiest author, How to?

My dear Calibre specialists, this is what I have done:

I have set a custom column Author Length (#AL).
this column populate with a numeric value, corresponding to the length of
fields Authors.

#AL as I have it is not very useful.

Is there a way to make #AL show not the length of the field Authors, but instead, the length of the lengthiest author of field Authors?

Example:
Authors = A. Star & Jessica Nicholls & Dariel Raye & Mia Darien & Abigail Owen & B. R. Kingsolver
#AL = 87
What I want to have:
#AL = 16 (Jessica Nicholls and B. R. Kingsolver are both 16 characters long,
while A. Star is 7, Dariel Raye is 11, Mia Darien is 10 and Abigail Owen is 12

Why do I want this?
So that a book with Authors "A. Star Jessica Nicholls Dariel Raye Mia Darien Abigail Owen B. R. Kingsolver" will show #AL = 77 and by that high value I can easily correct the Authors field.

Thank you very much in advance for your time and your help.
Tatjana is offline   Reply With Quote
Old 04-02-2018, 10:23 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,339
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you want to find books with large numbers of authors simply search for

authors:#>3

If you want to find books with a single very long author, simply sort by your #AL column and search for authors:#=1
kovidgoyal is offline   Reply With Quote
Advert
Old 04-02-2018, 04:19 PM   #3
Tatjana
Coffee Girl
Tatjana began at the beginning.
 
Tatjana's Avatar
 
Posts: 16
Karma: 10
Join Date: May 2014
Device: no money for such things
Kovid, some books I import have authors field like this:
"A. Star Jessica Nicholls Dariel Raye Mia Darien Abigail Owen B. R. Kingsolver"
No &, sometimes with commas instead &.
If I could have a custom column with the length of the lengthiest author, I could spot these books easily, otherwise, I simply don't know how to, except manually - what is hard for very big libraries. Thank you very much for your suggestions, I should have explained my reasons. I apologize.
Tatjana is offline   Reply With Quote
Old 04-02-2018, 06:20 PM   #4
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,046
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
In the tag browser: Right click any Author: Manage Authors.
A fast scroll thru the list.
those will stick out like a sore thumb.
Note: you can't fix Multiples here, only fix singles. ut now you know what to look for
theducks is offline   Reply With Quote
Old 04-02-2018, 09:32 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,339
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you want to find books with a single very long author, simply sort by your #AL column and search for authors:#=1

This will bring all books with long authors to the top, so you can fix them.
kovidgoyal is offline   Reply With Quote
Advert
Old 04-03-2018, 10:11 AM   #6
Tatjana
Coffee Girl
Tatjana began at the beginning.
 
Tatjana's Avatar
 
Posts: 16
Karma: 10
Join Date: May 2014
Device: no money for such things
Quote:
Originally Posted by kovidgoyal View Post
If you want to find books with a single very long author, simply sort by your #AL column and search for authors:#=1

This will bring all books with long authors to the top, so you can fix them.
Excellent!
I have been trying to do this for a very long time,
Thank you so very much!
Tatjana is offline   Reply With Quote
Old 04-03-2018, 10:29 AM   #7
Tatjana
Coffee Girl
Tatjana began at the beginning.
 
Tatjana's Avatar
 
Posts: 16
Karma: 10
Join Date: May 2014
Device: no money for such things
Quote:
Originally Posted by theducks View Post
In the tag browser: Right click any Author: Manage Authors.
A fast scroll thru the list.
those will stick out like a sore thumb.
Note: you can't fix Multiples here, only fix singles. ut now you know what to look for
Thank you, but it wouldn't be as fast as I need it to be.

Tatjana is offline   Reply With Quote
Old 04-03-2018, 03:36 PM   #8
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,046
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by Tatjana View Post
Thank you, but it wouldn't be as fast as I need it to be.

92K+ Authors
theducks is offline   Reply With Quote
Old 04-03-2018, 11:09 PM   #9
Tatjana
Coffee Girl
Tatjana began at the beginning.
 
Tatjana's Avatar
 
Posts: 16
Karma: 10
Join Date: May 2014
Device: no money for such things
Quote:
Originally Posted by theducks View Post
92K+ Authors


This is my "Ongoing" library, the final one has a lot more.
I have 3 main libraries:

Incoming, for new books, after a brief metadata cleanup books are moved to
Ongoing library, this one with 92K+ authors at the moment, usually a lot less, then they they are moved to the Final Digital library, that should have no metadata mistakes, but of course, it does

In my country, there are many public libraries that scan old documents into single massive PDF files, for example, a recent one I have been working on, is a single PDF with 2 centuries of a diary newspaper, since January first 1800 till December 31th 1999.

I have split it per day, then used ABBYY FineReader to get every issue it into readable form.

Then I noticed there was regular publications inside the newspaper, news from both WW wars, official royal decrees, local news, etc etc etc.

I have made EPUBs by year with all those "publications" separately.

Some of them like "letters from battlefront to family", have over hundreds authors.

During night, main database is not touched by Calibre, instead it is available for sync with any library who wants it, no matter who asks. All this publications belongs to us, to our common history and culture. I am just helping to organize it :-)

I don't do this because I am an historian, I do this because I love one, because I can do it, and if i don't do this, I am afraid nobody else will for a very long time.

Again, thank you for your help!
Tatjana is offline   Reply With Quote
Old 04-04-2018, 04:17 AM   #10
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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Tatjana View Post
I don't do this because I am an historian, I do this because I love one, because I can do it, and if i don't do this, I am afraid nobody else will for a very long time.
This inspires me to give you a solution. You can use a custom template function in a "column built from other columns".

The steps:
  1. Create the template function by going to Preferences / Advanced / Template Functions.
  2. Give the template a name. In this example I named it length_of_longest_author.
  3. Put a -1 in the Argument count box because the function takes no arguments.
  4. Put this text in the Program code box:
    Code:
    def evaluate(self, formatter, kwargs, mi, locals):
    	authors = mi.get('authors')
    	if authors:
    		return max([len(a) for a in authors])
    	return 0
    The following screen capture shows the example
    Click image for larger version

Name:	Clipboard01.jpg
Views:	215
Size:	223.9 KB
ID:	163238
  5. Create a custom column "built from other columns. Name it whatever you want. Set the template to
    Code:
    program: length_of_longest_author()
    using the name you used for the custom template function. Set the Sort/Search box to "Number". Check the "Show in Tag browser" box if you want to see the values in the tag browser. The following screen capture shows my example.
    Click image for larger version

Name:	Clipboard02.jpg
Views:	216
Size:	49.0 KB
ID:	163239
It will be interesting to see what performance this has on your large library.
chaley is offline   Reply With Quote
Old 04-04-2018, 07:23 AM   #11
Dopedangel
Wizard
Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.Dopedangel ought to be getting tired of karma fortunes by now.
 
Dopedangel's Avatar
 
Posts: 1,792
Karma: 30548723
Join Date: Dec 2006
Location: Singapore
Device: Boyue
Quote:
Originally Posted by chaley View Post
This inspires me to give you a solution. You can use a custom template function in a "column built from other columns".

The steps:
  1. Create the template function by going to Preferences / Advanced / Template Functions.
  2. Give the template a name. In this example I named it length_of_longest_author.
  3. Put a -1 in the Argument count box because the function takes no arguments.
  4. Put this text in the Program code box:
    Code:
    def evaluate(self, formatter, kwargs, mi, locals):
    	authors = mi.get('authors')
    	if authors:
    		return max([len(a) for a in authors])
    	return 0
    The following screen capture shows the example
    Attachment 163238
  5. Create a custom column "built from other columns. Name it whatever you want. Set the template to
    Code:
    program: length_of_longest_author()
    using the name you used for the custom template function. Set the Sort/Search box to "Number". Check the "Show in Tag browser" box if you want to see the values in the tag browser. The following screen capture shows my example.
    Attachment 163239
It will be interesting to see what performance this has on your large library.
That was my thought as well the performance hit using dynamic columns could be very large. Modifying the word count plugin to count author name size would be I think faster plus as the op needs the count for 1 time cleaning only wont require the columns to be updated with each author change.
Dopedangel is offline   Reply With Quote
Old 04-04-2018, 08:37 AM   #12
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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Dopedangel View Post
That was my thought as well the performance hit using dynamic columns could be very large.
Custom template functions run at python speed so this column might not have a large performance impact. It is easy enough to set it up and find out.
chaley is offline   Reply With Quote
Old 04-04-2018, 12:44 PM   #13
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,046
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by Dopedangel View Post
That was my thought as well the performance hit using dynamic columns could be very large. Modifying the word count plugin to count author name size would be I think faster plus as the op needs the count for 1 time cleaning only wont require the columns to be updated with each author change.
Why not add your template language to Bulk mode S&R for those 'one-time calc' uses? The 'replace' would be the target
theducks is offline   Reply With Quote
Old 04-04-2018, 01:17 PM   #14
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,440
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by theducks View Post
Why not add your template language to Bulk mode S&R for those 'one-time calc' uses? The 'replace' would be the target
It already is there. Use "template mode" as the source.
chaley is offline   Reply With Quote
Old 04-04-2018, 03:03 PM   #15
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,046
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by chaley View Post
It already is there. Use "template mode" as the source.

I was thinking it was simple templates
theducks is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Move selected data from series column to a new custom column fvdham Library Management 3 06-02-2017 03:49 PM
Custom COlumn: Author Sort - Series BzKevin Library Management 4 10-20-2014 09:27 AM
Sony book sorting by author fails when creating collections from a custom column speakingtohe Devices 2 05-15-2014 01:27 PM
Custom column returns value based on value of another custom column? calvin-c Calibre 3 09-14-2013 02:24 PM
Custom column showing path length? xterminal Library Management 1 09-11-2012 09:12 AM


All times are GMT -4. The time now is 04:18 PM.


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