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 12-11-2013, 04:23 PM   #1
Mixx
Zealot
Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.
 
Posts: 143
Karma: 387
Join Date: Sep 2010
Device: Kindle 3
Bulk Search & Replace Question (regexp)

Hi everyone,

I learned enough about regular expressions that I can extract parts of, say, titles to rearrange them. This time, however, I have a bunch of books of a series and the series number ended up in the title. I can extract that that serial number all right, but when I try to assign it to the series_index field I get the error message that it can not be converted to float.

How do I fix that? There must be some Python magic that is beyond by regexp skills.

Thanxx for any help,

Mixx

PS: May I suggest that in a future release this is taken care of and there is an automatic conversion to float (why float, why not integer BTW) if a number string is assigned to series_index?
Mixx is offline   Reply With Quote
Old 12-11-2013, 04:43 PM   #2
Adoby
Handy Elephant
Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.
 
Adoby's Avatar
 
Posts: 1,737
Karma: 26785684
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Samsung Galaxy Tab S8 Ultra
I suspect that your regexp contains other things than numbers. And that is why it can't be converted. You need to debug the regexp.

The series index is a float, not an integer. That is so you can specify decimal values like 1.40, if you wish. But you can also specify 1 or 2. Will automatically be converted to 1.00 and 2.00.
Adoby is offline   Reply With Quote
Advert
Old 12-12-2013, 01:18 AM   #3
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,353
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Mixx View Post
Hi everyone,

I learned enough about regular expressions that I can extract parts of, say, titles to rearrange them. This time, however, I have a bunch of books of a series and the series number ended up in the title. I can extract that that serial number all right, but when I try to assign it to the series_index field I get the error message that it can not be converted to float.

How do I fix that? There must be some Python magic that is beyond by regexp skills.

Thanxx for any help,

Mixx

PS: May I suggest that in a future release this is taken care of and there is an automatic conversion to float (why float, why not integer BTW) if a number string is assigned to series_index?
Search/Replace accepts integers just fine. As adoby said, you must be including some non-numeric characters in the result, such as the brackets.

Assuming the series is in brackets and that none contain decimal points, the search expression should be something like "^.*\[([\d])\].*$" and the replacement expression should be "\1"
chaley is offline   Reply With Quote
Old 12-12-2013, 01:53 AM   #4
Mixx
Zealot
Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.
 
Posts: 143
Karma: 387
Join Date: Sep 2010
Device: Kindle 3
My bad, it does work now, thanks a million.

Last edited by Mixx; 12-12-2013 at 02:05 AM.
Mixx is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bulk search & replace question Capricorn Calibre 0 08-23-2013 05:12 AM
Bulk search and replace operations - question SFD1968 Calibre 1 03-01-2013 09:23 AM
2 Questions about Bulk Edit Search & Replace BookJunkieLI Library Management 6 02-19-2012 01:39 PM
Search & Replace question - something not right curiosity Library Management 21 06-15-2011 11:33 AM
Setting series index in bulk metadata search&replace bubak Calibre 4 12-19-2010 04:04 PM


All times are GMT -4. The time now is 09:24 PM.


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