Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 01-19-2011, 08:09 AM   #46
beckywc
Addict
beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.
 
beckywc's Avatar
 
Posts: 272
Karma: 1050426
Join Date: Feb 2010
Location: California
Device: iPad Mini w/Retina, Kindle 3, Kindle Fire HDX 8.9, & Asus Transformer
Thanks that did the trick. Do you know why the different variations?
beckywc is offline   Reply With Quote
Old 01-19-2011, 08:13 AM   #47
beckywc
Addict
beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.
 
beckywc's Avatar
 
Posts: 272
Karma: 1050426
Join Date: Feb 2010
Location: California
Device: iPad Mini w/Retina, Kindle 3, Kindle Fire HDX 8.9, & Asus Transformer
I did notice that some that are showing the below example have a date in the column as if read:

In a magical world at war, passion abounds as four people are stripped to their souls, but will love or lust conquer all?
10/21/2010
Last Page Read: Location 35 (0%)

Is there any way to show this as reading?
beckywc is offline   Reply With Quote
Old 01-19-2011, 08:28 AM   #48
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,728
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
It is possible, but I have reached my limit. I don't have a kindle, so have no real reason to be doing this stuff. Perhaps a kindle owner will come along and take on the question.

Good luck...
chaley is offline   Reply With Quote
Old 01-19-2011, 09:39 AM   #49
beckywc
Addict
beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.
 
beckywc's Avatar
 
Posts: 272
Karma: 1050426
Join Date: Feb 2010
Location: California
Device: iPad Mini w/Retina, Kindle 3, Kindle Fire HDX 8.9, & Asus Transformer
Thank you so much. I really appreciate it.
beckywc is offline   Reply With Quote
Old 01-19-2011, 10:07 AM   #50
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi, Oasis
Thumbs up Having fun :-)

Quote:
Originally Posted by beckywc View Post
Thanks that did the trick. Do you know why the different variations?
Hi beckywc.
See you and chaley been having some fun
I only have the K3, and all my books have the same date format shown in the comments.
Don't really know why you have so many variations.
Sorry
pchrist7 is offline   Reply With Quote
Old 01-19-2011, 10:18 AM   #51
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi, Oasis
Date = Last opened

Quote:
Originally Posted by beckywc View Post
I did notice that some that are showing the below example have a date in the column as if read:

In a magical world at war, passion abounds as four people are stripped to their souls, but will love or lust conquer all?
10/21/2010
Last Page Read: Location 35 (0%)

Is there any way to show this as reading?
Hi again
You should think of the date as the time the book was last opened.
You can open a book without turning any pages, and thereby changing % read.

Show as reading ?
You mean the user column using the python template ?
Try changing the line
Code:
elif f > 0:
to
Code:
elif f >= 0:
Should work - does here.
pchrist7 is offline   Reply With Quote
Old 01-19-2011, 10:44 AM   #52
beckywc
Addict
beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.
 
beckywc's Avatar
 
Posts: 272
Karma: 1050426
Join Date: Feb 2010
Location: California
Device: iPad Mini w/Retina, Kindle 3, Kindle Fire HDX 8.9, & Asus Transformer
Quote:
Originally Posted by pchrist7 View Post
Hi again
You should think of the date as the time the book was last opened.
You can open a book without turning any pages, and thereby changing % read.

Show as reading ?
You mean the user column using the python template ?
Try changing the line
Code:
elif f > 0:
to
Code:
elif f >= 0:
Should work - does here.
No I was just using a template field in the custom column. I have in the template field:

{comments:'contains($, 'Last Page Read:', re($, '(?is).*(\d\d[-/]\d\d[-/]\d\d\d\d).*?Last Page Read:.*', '\1'), 'Not Read')'}

But I was wondering is there anyway if a book has been partially read to say reading, instead of the date.

Last edited by beckywc; 01-19-2011 at 10:47 AM.
beckywc is offline   Reply With Quote
Old 01-20-2011, 10:29 AM   #53
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi, Oasis
Exclamation Try this

Quote:
Originally Posted by beckywc View Post
No I was just using a template field in the custom column. I have in the template field:

{comments:'contains($, 'Last Page Read:', re($, '(?is).*(\d\d[-/]\d\d[-/]\d\d\d\d).*?Last Page Read:.*', '\1'), 'Not Read')'}

But I was wondering is there anyway if a book has been partially read to say reading, instead of the date.
Hi bechywc.
Havent had enough time to look at this. Want to, cause this is fun.
A bit hard to learn, but ...
SO - you don't want the last opened date ?
OR you want another custom column showing "read" status ?
Please explain further. Please understand English is not my native language.
So please be precise.
Also, how many books do you have in your Calibre library ?
I have 900, and some of these customn columns using "just" templates, slows Calibre startup from 1-2 second to 1-2 minuttes.
That's why I asked chaley, brilliant work, to help with the python Template functions.

Anyways.
A quick, (slow with many books, not nice) fix for a new column could be:

Code:
{comments:'contains($, 'Last Page Read:', re($, '(?is).*\s(\d+[-/]\d+[-/]\d\d\d\d).*?Last Page Read:.*', 'Reading'), 'Not Read')'}
IF you want to go for a more detailed distinction for the amount (%) read, I suggest the python way. ( need to learn that too )
Please let me know what you're looking for.

Edit:
Simpler template than above, could be faster.
Code:
{comments:'contains($,'Last Page Read: ', 'Read', 'Not Read')'}

Last edited by pchrist7; 01-20-2011 at 10:39 AM. Reason: spelling, new code
pchrist7 is offline   Reply With Quote
Old 01-20-2011, 01:17 PM   #54
beckywc
Addict
beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.
 
beckywc's Avatar
 
Posts: 272
Karma: 1050426
Join Date: Feb 2010
Location: California
Device: iPad Mini w/Retina, Kindle 3, Kindle Fire HDX 8.9, & Asus Transformer
What I want the custom column to show is the date read if > 95%. If the book shows >0% but < 95% I want the colunn to show reading and if the book is 0% or unopened not read.

So I probably do need a program code, I just don't know how to do it. Trying to read and figure out how to program in python and I feel utterly lost.

Thanks so much for your time.
beckywc is offline   Reply With Quote
Old 01-21-2011, 05:57 AM   #55
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi, Oasis
Ahh - now I understand

Quote:
Originally Posted by beckywc View Post
What I want the custom column to show is the date read if > 95%. If the book shows >0% but < 95% I want the colunn to show reading and if the book is 0% or unopened not read.

So I probably do need a program code, I just don't know how to do it. Trying to read and figure out how to program in python and I feel utterly lost.

Thanks so much for your time.
Hi beckywc
Got it.
wonder if it can be done.
Will give it a try or two during the weekend.
pchrist7 is offline   Reply With Quote
Old 01-21-2011, 11:26 AM   #56
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,728
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by pchrist7 View Post
Hi beckywc
Got it.
wonder if it can be done.
Will give it a try or two during the weekend.
You can do it.

Try playing with some variant of this
Code:
def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct, is_read_str, 
				is_reading_str, no_page_read_str):
	try:
		test_val = int(is_read_pct)
	except:
		return 'is_read_pct is not a number'

	import re
	mg = re.match('\s(\d+[-/]\d+[-/]\d\d\d\d).*?Last Page Read: location \d+ \((\d+)%\)', val, re.I + re.DOTALL);
	if mg is None:
		return no_page_read_str
	date = mg.group(1)
	pct = mg.group(2)
	try:
		f = int(pct)
		if f >= test_val:
			return date
		return is_reading_str + ': ' + pct + '%'
	except:
		pass
	return no_page_read_str
I haven't tried it, so it might not compile. Should be close.

I changed the regexp in the re(...) clause to carve out both the date and the percent. If it finds them, then the ifs below choose what to return.

Have fun.
chaley is offline   Reply With Quote
Old 01-22-2011, 02:11 AM   #57
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi, Oasis
Thanks !

Quote:
Originally Posted by chaley View Post
You can do it.

Try playing with some variant of this
Code:
def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct, is_read_str, 
				is_reading_str, no_page_read_str):
	try:
		test_val = int(is_read_pct)
	except:
		return 'is_read_pct is not a number'

	import re
	mg = re.match('\s(\d+[-/]\d+[-/]\d\d\d\d).*?Last Page Read: location \d+ \((\d+)%\)', val, re.I + re.DOTALL);
	if mg is None:
		return no_page_read_str
	date = mg.group(1)
	pct = mg.group(2)
	try:
		f = int(pct)
		if f >= test_val:
			return date
		return is_reading_str + ': ' + pct + '%'
	except:
		pass
	return no_page_read_str
I haven't tried it, so it might not compile. Should be close.

I changed the regexp in the re(...) clause to carve out both the date and the percent. If it finds them, then the ifs below choose what to return.

Have fun.
Hi Chaley
Thanks a lot. You probably saved a lot testing hours, trying to grab the date.
Will test a bit later today when I'm home from work.
pchrist7 is offline   Reply With Quote
Old 01-22-2011, 03:59 AM   #58
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,728
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by pchrist7 View Post
Hi Chaley
Thanks a lot. You probably saved a lot testing hours, trying to grab the date.
Will test a bit later today when I'm home from work.
You are welcome.

Just noticed: you must use re.match('.*\s(\d+ (note the new .* at the beginning of the string). It won't work as I wrote it, because re.match is an anchored search. The pattern must match all characters from the beginning. This is done to ensure efficient location of the last annotation group.
chaley is offline   Reply With Quote
Old 01-22-2011, 04:54 AM   #59
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi, Oasis
Thumbs up Got it !

Quote:
Originally Posted by chaley View Post
You can do it.

I haven't tried it, so it might not compile. Should be close.

I changed the regexp in the re(...) clause to carve out both the date and the percent. If it finds them, then the ifs below choose what to return.

Have fun.
Hi Chaley
You were SO close !
All I had to do was add .* in re.match since the date is not at the start of comments. RTFM helped with that one
Bit tricky to find. Added more return strings to determine that mg was empty.
Now I know what I wish for my birthday: python debugger, line by line, integrated in Calibre
I know, keep dreaming.
How do you debug ? Just looking, trying, etc. ?

@beckywc: Will post my suggestions for you shortly.
pchrist7 is offline   Reply With Quote
Old 01-22-2011, 04:56 AM   #60
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi, Oasis
Refresh page before posting. Sigh

Quote:
Originally Posted by chaley View Post
You are welcome.

Just noticed: you must use re.match('.*\s(\d+ (note the new .* at the beginning of the string). It won't work as I wrote it, because re.match is an anchored search. The pattern must match all characters from the beginning. This is done to ensure efficient location of the last annotation group.
Hi Chaley
Posted before reading this post.
Good part is I figured it out myself !
Thank you, once more
pchrist7 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
"integrity error column book is not unique" Atiajar Calibre 4 12-21-2010 11:22 PM
Can Comments be "saved to disk" for reading? sailingpeanut Recipes 1 10-10-2010 10:06 AM
(2 books) in "On Device" column Sony Reader phenomshel Calibre 23 09-19-2010 05:43 PM
Bug? "Insert metadata as page at start of book" doesnt encode Comments field properly rollercoaster Calibre 2 04-24-2010 10:40 PM


All times are GMT -4. The time now is 05:43 PM.


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