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-25-2020, 04:54 PM   #1
sasilk
Connoisseur
sasilk began at the beginning.
 
sasilk's Avatar
 
Posts: 75
Karma: 14
Join Date: Jun 2008
Location: Australia
Device: iPad Pro 12"; Kindle Paperwhite
Question Search & Replace in multi value field

Hi,

I have a situation where a metadata reader has added half of the title and the author as two separate authors in the 'authors' field. In all cases, the incorrect data is the first entry in the multi value field.

Normally I'd just fix it by hand, but there's 2000 of them, and I suspect it's going to happen again (it has already) so I'd like to find an automated fix.

In the bulk metadata Search & Replace, I can isolate either the first value or all of the subsequent values (usually only one) using the "For multivalue fields, show <x> values starting at <y> with values separated by <xxx>" but I can't get the Replace part to work - it simply leaves it as is. It displys it correctly in the GUI, but doesn't seem to write anything.

Strangely, I can get it to work with the 'authors_sort' field (using the regex "^.*\& " and the multi value settings as above), but can't find a way to bulk set the 'authors' field from the 'author_sort' field.

If anyone has an answer to either issue (preferably the first, but I'm not going to be picky :-D ) I'd be really grateful.


Thank you!
Stephen

Last edited by sasilk; 03-25-2020 at 04:57 PM.
sasilk is offline   Reply With Quote
Old 03-25-2020, 05:24 PM   #2
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: 29,845
Karma: 54837878
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Picture (textual examples) is worth a 1K words

Example(s) please
Please use the attachment method (paperclip in MR advanced mode) for any screen captures.
Indicate a start with (right from add source)
(optional) current from what I have done
want it to be
theducks is offline   Reply With Quote
Advert
Old 03-25-2020, 06:06 PM   #3
sasilk
Connoisseur
sasilk began at the beginning.
 
sasilk's Avatar
 
Posts: 75
Karma: 14
Join Date: Jun 2008
Location: Australia
Device: iPad Pro 12"; Kindle Paperwhite
Angry

I think 4 hours of searching this forum, along with another couple of hours learning enough to debug some regex code that a friend helped me with before asking probably counts. I've been trying to work out a solution to this for 14 hours now, since around 7pm last night (it's almost 9am here now), but sure, assume that I've done absolutely nothing.

Didn't you notice that I'd managed to achieve some progress already, including multiple approaches and what they did and didn't achieve? That should have given you a clue that I'd been working on it myself and wasn't just asking for a whole solution first up. I gave you TWO approaches I'd worked out, one of which didn't work and the other which did, but imperfectly. And the phrase "I can't find a way" would suggest that I'd been searching I would have thought.

But no. It appears that I have to explain - in detail - every single thing I've done and tried before I'm worthy of your munificence.

I don't post here often - mainly because I work out solutions to most things either by myself or via searching for them. And now I'm kind of glad I don't have to, with this kind of supercilious response. Are you here to be helpful, or to further inflate your enormous ego?
sasilk is offline   Reply With Quote
Old 03-25-2020, 06:25 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: 29,845
Karma: 54837878
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 sasilk View Post
I think 4 hours of searching this forum, along with another couple of hours learning enough to debug some regex code that a friend helped me with before asking probably counts. I've been trying to work out a solution to this for 14 hours now, since around 7pm last night (it's almost 9am here now), but sure, assume that I've done absolutely nothing.

Didn't you notice that I'd managed to achieve some progress already, including multiple approaches and what they did and didn't achieve? That should have given you a clue that I'd been working on it myself and wasn't just asking for a whole solution first up. I gave you TWO approaches I'd worked out, one of which didn't work and the other which did, but imperfectly. And the phrase "I can't find a way" would suggest that I'd been searching I would have thought.

But no. It appears that I have to explain - in detail - every single thing I've done and tried before I'm worthy of your munificence.

I don't post here often - mainly because I work out solutions to most things either by myself or via searching for them. And now I'm kind of glad I don't have to, with this kind of supercilious response. Are you here to be helpful, or to further inflate your enormous ego?
What is with the Attitude?
I asked for an example, rather than GUESS (wrong).
I guess that is too much to ask from someone who asked for help from VOLUNTEERS .
theducks is offline   Reply With Quote
Old 03-25-2020, 06:31 PM   #5
sasilk
Connoisseur
sasilk began at the beginning.
 
sasilk's Avatar
 
Posts: 75
Karma: 14
Join Date: Jun 2008
Location: Australia
Device: iPad Pro 12"; Kindle Paperwhite
All I got in your reply(ies) is your tagline.

Last edited by sasilk; 03-25-2020 at 06:55 PM.
sasilk is offline   Reply With Quote
Advert
Old 03-25-2020, 06:41 PM   #6
sasilk
Connoisseur
sasilk began at the beginning.
 
sasilk's Avatar
 
Posts: 75
Karma: 14
Join Date: Jun 2008
Location: Australia
Device: iPad Pro 12"; Kindle Paperwhite
Ahhh, just figured out the problem. Your replies were coming through as blanks, with just your tagline, so I thought that was the reply. My apologies - complete misunderstanding on my part.

Stephen
sasilk is offline   Reply With Quote
Old 03-25-2020, 07:23 PM   #7
sasilk
Connoisseur
sasilk began at the beginning.
 
sasilk's Avatar
 
Posts: 75
Karma: 14
Join Date: Jun 2008
Location: Australia
Device: iPad Pro 12"; Kindle Paperwhite
Here's a screenshot of where I stand, showing the situation on the main screen, with what I get on the Search & Replace. I can isolate either the correct value or the incorrect value from the authors field and have it show up in the right-hand column of the Test Result section, but it doesn't seem to write correctly.

I suspect that's because there's nothing in the Replace With dialogue field.

What I would like is to have the incorrect value show up on the left (I can achieve that) and nothing on the right, meaning that the icorrect value would be replaced with NULL. (YEs, I tried a space but that didn't work either.)

I guess what I'm asking, in a nutshell, is how do I delete a numbered member of a multi-value field?
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2020-03-26 at 10.02.54.jpg
Views:	134
Size:	922.7 KB
ID:	177910  
sasilk is offline   Reply With Quote
Old 03-25-2020, 07:42 PM   #8
sasilk
Connoisseur
sasilk began at the beginning.
 
sasilk's Avatar
 
Posts: 75
Karma: 14
Join Date: Jun 2008
Location: Australia
Device: iPad Pro 12"; Kindle Paperwhite
Further investigation indicates that it's not treating the results as a string, but as a set of string values. And the "For multivalue firlds" bit is simply displaying them, and has nothing to do with what's getting changed. Now, is there a way to indicate which numbered value you want?
sasilk is offline   Reply With Quote
Old 03-25-2020, 07:50 PM   #9
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: 29,845
Karma: 54837878
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Now I see
You need to a capture portion

I use REGEX mode (the saved search in my Example, did not have it set)
The original was: TheSeries 1 - title

There are 3 sets of captures (this one is for Title portion Only)
DO the Source field (Title) LAST as that replace deletes the other field values

Title is the 3rd capture, thus the \3

If you were populating Series, the destination would be Series and the value \1
then you populate the Series Index and the replace value is \2
I never could get Series to work as a single step

Does this help get you going?
Attached Thumbnails
Click image for larger version

Name:	BLKS&R.PNG
Views:	125
Size:	57.8 KB
ID:	177912  
theducks is offline   Reply With Quote
Old 03-25-2020, 08:19 PM   #10
sasilk
Connoisseur
sasilk began at the beginning.
 
sasilk's Avatar
 
Posts: 75
Karma: 14
Join Date: Jun 2008
Location: Australia
Device: iPad Pro 12"; Kindle Paperwhite
I've worked out a way of doing it using template input mode. Working out that it was treating each value separately was the bit I needed.

If I use {authors} as the input, search for everything up to the first '&' and replace that with NULL, then write the remaining string into destination field authors it work perfectly. (Only because the incorrect value is always the first one.)
sasilk is offline   Reply With Quote
Old 03-25-2020, 08:24 PM   #11
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: 29,845
Karma: 54837878
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Template mode works for many
theducks is offline   Reply With Quote
Old 03-25-2020, 08:38 PM   #12
sasilk
Connoisseur
sasilk began at the beginning.
 
sasilk's Avatar
 
Posts: 75
Karma: 14
Join Date: Jun 2008
Location: Australia
Device: iPad Pro 12"; Kindle Paperwhite
Thanks for the help. I'll keep your suggestion for other possible needs. And again, my apologies for the crap I gave you.
sasilk is offline   Reply With Quote
Old 03-25-2020, 09:36 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: 29,845
Karma: 54837878
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 sasilk View Post
Thanks for the help. I'll keep your suggestion for other possible needs. And again, my apologies for the crap I gave you.
Did you ever find out why you could only see my Sig?
theducks is offline   Reply With Quote
Old 03-25-2020, 10:18 PM   #14
sasilk
Connoisseur
sasilk began at the beginning.
 
sasilk's Avatar
 
Posts: 75
Karma: 14
Join Date: Jun 2008
Location: Australia
Device: iPad Pro 12"; Kindle Paperwhite
Yes. For some odd reason you were on my ignore list.
sasilk is offline   Reply With Quote
Old 03-26-2020, 02:15 AM   #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: 29,845
Karma: 54837878
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 sasilk View Post
Yes. For some odd reason you were on my ignore list.
That will do it. (I had not realized my post would even show in that mode. It has been years since I Ignored a Poster and I should not hide anyone in this forum: Mod duties )
theducks is offline   Reply With Quote
Reply

Tags
multi value field, regex, search & replace


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Request: multi-search and multi-replace regex question iienderii Library Management 1 04-17-2016 03:15 PM
Search and Replace: want to remove value that matches another field einniv Library Management 0 07-25-2013 08:18 PM
Using Search & Replace with Identifiers field BookJunkieLI Calibre 6 11-13-2012 01:20 PM
Multi-field search ElfN Library Management 2 07-21-2012 09:36 AM
Variable Search, Replace & Transfer to a new field flopis Library Management 10 03-09-2011 11:41 AM


All times are GMT -4. The time now is 12:48 PM.


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