Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 09-17-2010, 10:06 AM   #16
pckopp
Enthusiast
pckopp began at the beginning.
 
Posts: 32
Karma: 44
Join Date: Jul 2010
Location: Seneca, SC
Device: Kindle, eReader
I should read _before_ typing. This works:

[[](?P<series>.+)[]] (?P<title>.+) - (?P<author>[^_]+)

EDIT: Works perfectly in the test box but not in the actual Add Books process. Acts like the original title - author expression. Huh?

Quote:
Originally Posted by pckopp View Post
I'm one of the users for whom RE is a barely understood concept, so can I just ask a question related to adding books?

My current expression: (?P<title>.+) - (?P<author>[^_]+)

works great. But sometimes I have a filename that includes the series info at the beginning in brackets. Like this:

[Instrumentality Of Mankind] Golden the Ship Was Oh! Oh! Oh! - Cordwainer Smith.epub

I would like the text between the brackets to be in the Series box.

Thanks!

Last edited by pckopp; 09-17-2010 at 10:27 AM.
pckopp is offline   Reply With Quote
Old 09-17-2010, 10:24 AM   #17
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by chaley View Post
<pontification>
From a development standpoint, it wouldn't be hard ...
</pontification>
I completely agree with this view. However, (no that doesn't mean I'm going to backtrack .... much) Calibre does inhabit the high end when it comes to the technical sophistication of users and the skills needed to use many features. Extra CSS, regex expressions in multiple locations and XPath for TOC require a lot of skill, even with Kovid's excellent wizards.

If I was still struggling through my initial stages of data entry, I would have loved to have had a sticky thread with useful Python code fragments that could be executed with:
Quote:
calibre-debug -e myscript.py
.
It would have a first post saying there's no bulk undo, use at your own risk, make a backup first, etc. Then some scripts like:
Regex search and replace in title or author.
Populate a field with the contents of other fields or data.
etc.

People could add scripts, as they do recipes, as they're written. I clearly remember my frustration when I couldn't easily directly modify the metadata.db SQL database to do regex searches and fix miscellaneous errors in title/author.

I have to say that in view of the many recent improvements in Calibre, I want such scripts a lot less (plus I'm no longer actively adding my old ebook library).

Still, I have no problem with providing some options (outside the Calibre installed environment) to help the most sophisticated Calibre users who are willing to run at the bleeding edge and take the consequences.

Last edited by Starson17; 09-17-2010 at 10:28 AM.
Starson17 is offline   Reply With Quote
Advert
Old 09-17-2010, 03:15 PM   #18
gwk
Junior Member
gwk began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Sep 2010
Device: irex iliad, htc hd2
And that chaley would really be perfect.
Throw a regexp in the mix, for the regexp people on this planet, and it would do the job.

By the way, I recognize the regexp issues, not that many people know how to create them.

With respect to python scripts.
They could almost serve as a kind of small apps which the community can add to Calibre.
When apps become popular, simply add them as feature to calibre.

But a bit of basic plumbing and community attention is required, like
- some small examples
- a menu ability in Calibre - which adds for instance the ability to run it against a selection of books (not sure how to do that from the command line)
- a place to post them
- a means to add review comments, etc
- moderation and management

While the first and second items are relatively easy to achieve, the rest requires far more attention and work to pull it off.

Not sure how this worked for the news sources, probably that is the best example.

Last edited by gwk; 09-17-2010 at 03:32 PM.
gwk is offline   Reply With Quote
Old 09-17-2010, 03:23 PM   #19
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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by gwk View Post
And that chaley would really be perfect.
Throw a regexp in the mix, for the regexp people on this planet, and it would do the job.
The search string is a python regexp pure and simple. The replacement string is a python replacement string (can contain backreferences). The function is one of null, lower case, title case, or upper case, and it is applied after backreference substitution.

It will be in today's release, marked as experimental. Backup your library before hacking.
chaley is offline   Reply With Quote
Old 09-17-2010, 03:41 PM   #20
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by chaley View Post
The search string is a python regexp pure and simple. The replacement string is a python replacement string (can contain backreferences). The function is one of null, lower case, title case, or upper case, and it is applied after backreference substitution.

It will be in today's release, marked as experimental. Backup your library before hacking.
Cool! How about something similar that fills a field from other fields with {title} or {isbn} references, etc.? It would let you build a copy of a field (say copy all {title} into it or all {isbn}), then run the new experimental S&R on the new field with less risk of destruction. Later you could send the modified field back into the real title. I've occasionally wanted to send tags into comments, or custom text fields into tags, but even text only to text only would have some uses for me.

Last edited by Starson17; 09-17-2010 at 03:43 PM.
Starson17 is offline   Reply With Quote
Advert
Old 09-17-2010, 03:48 PM   #21
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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Starson17 View Post
Cool! How about something similar that fills a field from other fields with {title} or {isbn} references, etc.? It would let you build a copy of a field (say copy all {title} into it or all {isbn}), then run the new experimental S&R on the new field with less risk of destruction. Later you could send the modified field back into the real title.
Sounds like you want undo.

In effect, you are asking for some kind of scripting language that supports some level of transform on fields, including copying from one to another. There be dragons here. Such languages never stop growing.

It seems more reasonable to use python plugins for this. Thought is required.
chaley is offline   Reply With Quote
Old 09-17-2010, 03:56 PM   #22
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by chaley View Post
<pontification>
[...]
</pontification>
That's a very good post. I've already noticed a rise in threads about regexp matching for header/footer removal and such, asking just about the same questions all the time. (I actually thought about writing a tutorial, but seeing as I'm just beginning to understand them, I might not be the right guy for that. I haven't fully groked how to cope with linebreaks and somesuch...)

That being said, I really like your mockup. Provided it understands regular expressions as well as "normal" strings (wait, that would be a regular expression in itself... nevermind), it's a gorgeous and, I think, very powerful feature.
Manichean is offline   Reply With Quote
Old 09-17-2010, 04:02 PM   #23
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by chaley View Post
Sounds like you want undo.
No, although the ability to work on a copy of a field would be nice. It's merely that I occasionally have wanted to move field contents around.

Quote:
In effect, you are asking for some kind of scripting language that supports some level of transform on fields, including copying from one to another. There be dragons here. Such languages never stop growing.

It seems more reasonable to use python plugins for this. Thought is required.
I had in mind simple field copying to start. Select the destination field to be acted upon and another field as source. Have the source field appended to the destination field. With that, and your regex field processing, I could do anything to the fields I've ever wanted to do.
Starson17 is offline   Reply With Quote
Old 09-17-2010, 04:15 PM   #24
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by Starson17 View Post
Cool!
Charles. I've tested it, and it works great! The only comment I have is that I'd prefer to leave the highlighting/selection on the previously selected books, so I can hit them several times without reselecting each time.
Starson17 is offline   Reply With Quote
Old 09-17-2010, 04:19 PM   #25
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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Starson17 View Post
I had in mind simple field copying to start. Select the destination field to be acted upon and another field as source. Have the source field appended to the destination field. With that, and your regex field processing, I could do anything to the fields I've ever wanted to do.
What would you do about multiplicity? Could you require that the source and destination be the same? If they are not, then you can have all sorts of bizarre behavior, such as authors being munged together because the separating ',' was deleted.

In any event, I think you are suggesting something like:
0. verify that source and dest have the same multiplicity.
1. get value from source
2. process it with regexp, taking into account multiplicity
3. store result in dest.
chaley is offline   Reply With Quote
Old 09-17-2010, 04:23 PM   #26
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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Starson17 View Post
Charles. I've tested it, and it works great!
Good. Nice to know I don't need to beg Kovid to yank it from the release he is in process of making.
Quote:
The only comment I have is that I'd prefer to leave the highlighting/selection on the previously selected books, so I can hit them several times without reselecting each time.
The problem is that bulk edit does a resort/re-search when it finishes, often rendering the previous selection invalid. One could argue that it shouldn't do that, but that is an issue to take up with Kovid.
chaley is offline   Reply With Quote
Old 09-17-2010, 04:34 PM   #27
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: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by chaley View Post
The problem is that bulk edit does a resort/re-search when it finishes, often rendering the previous selection invalid. One could argue that it shouldn't do that, but that is an issue to take up with Kovid.
Well even if it does a resort there's no reason it cant reselect the previously selected entries once its done.
kovidgoyal is offline   Reply With Quote
Old 09-17-2010, 04:34 PM   #28
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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Manichean View Post
I've already noticed a rise in threads about regexp matching for header/footer removal and such, asking just about the same questions all the time.
I also have noticed this. GRiker gets many of them. However, I think that questions about regexps and pdfs are the winners. And I just made it worse.
Quote:
(I actually thought about writing a tutorial, but seeing as I'm just beginning to understand them, I might not be the right guy for that. I haven't fully groked how to cope with linebreaks and somesuch...)
Writing such a tutorial would be fantastic. And your 'beginning' state might help. If you have time, then please give it a try. There is a lot of incentive here for experts to help check what you do for technical accuracy.
Quote:
That being said, I really like your mockup. Provided it understands regular expressions as well as "normal" strings (wait, that would be a regular expression in itself... nevermind), it's a gorgeous and, I think, very powerful feature.
Isn't that a wonder feature of regexps? Any string can match itself, so it is a regexp! When I was teaching programming language compiler construction (regexps have a huge role there), students would light up when they figured that out. Understanding that a regexp is just a string that matches other strings takes much of the magic out of it. Once we have that, all we are really worrying about is what a character is.
chaley is offline   Reply With Quote
Old 09-17-2010, 04:36 PM   #29
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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kovidgoyal View Post
Well even if it does a resort there's no reason it cant reselect the previously selected entries once its done.
As long as they are still visible. And as long as we are willing to have the selections scattered all over the map.

If you are OK with this, I will look at doing it.

One rule: I don't think we should select items that are no longer visible.
chaley is offline   Reply With Quote
Old 09-17-2010, 04:41 PM   #30
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: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yeah, I'm fine with it. You'll need to add select_row function to BooksView analogous to the set_current_row.
kovidgoyal is offline   Reply With Quote
Reply

Tags
metadata, replace, search


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CALIBRE WILL NOT RECOGNISE TITLES OR AUTHORS D.. Calibre 5 09-14-2010 09:33 PM
Classic PDF titles and authors on nook? slothrop Barnes & Noble NOOK 2 12-09-2009 09:23 PM
Issues Editing Titles & Authors kmvargo Calibre 0 07-05-2009 12:43 AM
Authors/Titles different font sizes bunjibear Sony Reader 6 03-15-2009 10:41 AM
Changes in Titles/Authors Not Shown Ralob Bookeen 20 04-07-2008 08:16 AM


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


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