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 09-04-2014, 08:00 AM   #541
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,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by DMee View Post
Don't suppose there's any way of getting it to use any other character in place of space?

I could live with, say, underscores

__32
_132
1999

??
{series_index:_>6d}
chaley is offline   Reply With Quote
Old 09-04-2014, 08:04 AM   #542
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,850
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You could probably get it to use one of the various unicode spaces like the non-breaking space or the thin space/thick space. I doubt those space characters are compressed.
kovidgoyal is offline   Reply With Quote
Advert
Old 09-04-2014, 11:56 AM   #543
DMee
Zealot
DMee began at the beginning.
 
Posts: 116
Karma: 10
Join Date: Jun 2011
Location: Stockport, UK
Device: ipad, iphone, kindle
Aaaargh!! Thought you had cracked it then but....

PLUGBOARD TEMPLATE ERROR format: type d requires an integer..

Can't handle my 0.25 series numbers :-(

I give up :-(
DMee is offline   Reply With Quote
Old 09-04-2014, 12:30 PM   #544
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,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by DMee View Post
Aaaargh!! Thought you had cracked it then but....

PLUGBOARD TEMPLATE ERROR format: type d requires an integer..

Can't handle my 0.25 series numbers :-(

I give up :-(
I didn't realize you were using floating point numbers. This template handles them
Code:
{series_index:_>7.2f}
chaley is offline   Reply With Quote
Old 09-05-2014, 06:31 AM   #545
DMee
Zealot
DMee began at the beginning.
 
Posts: 116
Karma: 10
Join Date: Jun 2011
Location: Stockport, UK
Device: ipad, iphone, kindle
FINALLY

WOOOOOO

I owe you a pint
DMee is offline   Reply With Quote
Advert
Old 09-05-2014, 06:34 AM   #546
DMee
Zealot
DMee began at the beginning.
 
Posts: 116
Karma: 10
Join Date: Jun 2011
Location: Stockport, UK
Device: ipad, iphone, kindle
OK, now I know it can be done - is there any simple, easy way to swap plugboards so I can use the simple setup for most books and then use this for those awkward series?
DMee is offline   Reply With Quote
Old 09-05-2014, 11:23 AM   #547
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Use a custom column to set which ones deserve the new template (or tag them) and do a list lookup to determine which template to use. When I get on the computer I will work out a general program mode template to do it, assuming no one beats me to it.
eschwartz is offline   Reply With Quote
Old 09-05-2014, 03:16 PM   #548
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Okay, so assuming you want "Series Name [03] Book Title" as per post #533.

series_index should be prepended with underscores, to bump it up to 4 digits.

If the custom column "#complex_series" is set to true -- I'll just test if it has any value -- it will add two decimal places. Mark each awkward series with this.
(This would be easier if I could figure out how to test within a template for a numer with decimals.)

Template should be:
Code:
program:

ser_num = test(
	field('#complex_series'),
	finish_formatting(
		field('series_index'),
		'_>7.2f',
		' [',
		'] '
	),
	finish_formatting(
		field('series_index'),
		'_>4d',
		' [',
		'] '
	),
);

strcat(
	field('series'),
	ser_num,
	field('title')
)
(You can delete whitespace if you want, but I left it in to clarify what I am doing.)

Last edited by eschwartz; 09-05-2014 at 03:18 PM.
eschwartz is offline   Reply With Quote
Old 09-06-2014, 05:41 AM   #549
DMee
Zealot
DMee began at the beginning.
 
Posts: 116
Karma: 10
Join Date: Jun 2011
Location: Stockport, UK
Device: ipad, iphone, kindle
O.....K......
Mind officially blown

At moment I am using metadata plugboard which allows me to email any book to my kindle and get it formatted as I want.

So, idiot instructions please. Where does this code go and how do I alter my workflow to use it??
DMee is offline   Reply With Quote
Old 09-06-2014, 06:10 AM   #550
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,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by eschwartz View Post
If the custom column "#complex_series" is set to true -- I'll just test if it has any value -- it will add two decimal places. Mark each awkward series with this.
(This would be easier if I could figure out how to test within a template for a numer with decimals.)
The following tests whether a number is an integer by comparing the integer formatted value against the floating point formatted value.
Code:
program: 
	sindex = raw_field("series_index");
	cmp(format_number(sindex, '{0:d}'), format_number(sindex, '{0:f}'), 'not int', 'int', 'not int')
chaley is offline   Reply With Quote
Old 09-06-2014, 07:09 AM   #551
DMee
Zealot
DMee began at the beginning.
 
Posts: 116
Karma: 10
Join Date: Jun 2011
Location: Stockport, UK
Device: ipad, iphone, kindle
Chaley, if that checks on a per-item basis it won't trigger for all the books in the series, just those with fractions?
DMee is offline   Reply With Quote
Old 09-06-2014, 03:14 PM   #552
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,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by DMee View Post
Chaley, if that checks on a per-item basis it won't trigger for all the books in the series, just those with fractions?
You are right. I answered what I thought was the question, but clearly I was confused.

I have a python "script" that puts the correct format for a series into a custom column. It looks at all books in the series, figures out whether it needs decimals and how many leading zeros (could be underscores) are required, and then writes the correct format for "format_number" to the custom column for each book in the series. The script is run from the command line with calibre-debug -e. I mention this mostly to agree that I was being dense, especially as I had already solved this problem in a different way, but if you are comfortable with this sort of thing you are welcome to use the script appropriately modified.

The script is:
Spoiler:
Code:
def init_cache(library_path):
	from calibre.db.backend import DB
	from calibre.db.cache import Cache
	backend = DB(library_path)
	cache = Cache(backend)
	cache.init()
	return cache

import math
from collections import defaultdict
	
cache = init_cache(library_path = 'path-to-your-library')
series_info = defaultdict(dict)

for id_ in cache.all_book_ids():
	series = cache.field_for('series', id_)
	if series:
		sidx = cache.field_for('series_index', id_)
		str_sidx = str(sidx)
		components = str_sidx.split('.')
		if components[1] == '0':
			fract_part = 0
		else:
			fract_part = len(components[1])
		val_part = len(components[0])
		series_info[series]['val_part'] = max(series_info[series].get('val_part', 0), val_part)
		series_info[series]['fract_part'] = max(series_info[series].get('fract_part', 0), fract_part)
		
for series,sinfo in series_info.iteritems():
	fract_part = sinfo['fract_part']
	format_str = '{0:0%d.%df}'%(sinfo['val_part'] + fract_part + (1 if fract_part > 0 else 0), fract_part)
	sids = cache.search('series:"=' + series + '"')
	dct = {book_id:format_str for book_id in sids}
	cache.set_field('#text', dct)
chaley is offline   Reply With Quote
Old 09-07-2014, 12:17 AM   #553
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by chaley View Post
The following tests whether a number is an integer by comparing the integer formatted value against the floating point formatted value.
Code:
program: 
	sindex = raw_field("series_index");
	cmp(format_number(sindex, '{0:d}'), format_number(sindex, '{0:f}'), 'not int', 'int', 'not int')
Must keep this trick in mind. I knew there had to be something.
Quote:
Originally Posted by DMee View Post
Chaley, if that checks on a per-item basis it won't trigger for all the books in the series, just those with fractions?
And I didn't think of this either. So it was not you who was confused, chaley.

Last edited by eschwartz; 09-07-2014 at 12:21 AM.
eschwartz is offline   Reply With Quote
Old 09-07-2014, 01:28 AM   #554
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,957
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
delete post

Last edited by JSWolf; 09-07-2014 at 01:34 AM.
JSWolf is offline   Reply With Quote
Old 09-09-2014, 12:13 PM   #555
EnergyLens
Hack
EnergyLens began at the beginning.
 
Posts: 34
Karma: 12
Join Date: Dec 2009
Device: Kobo Aura HD, Kindle Paperwhite
composite column template TRUE if ONLY format = PDF

I thought this would be easy, but I am totally lost.

I know how to do a search for only PDF by excluding other formats, but I don't know how to use the template language to do the same...

Can someone give me a quick pointer?
EnergyLens is offline   Reply With Quote
Reply

Tags
custom column, tag, tags


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
custom column i need a little help shinken Calibre 3 09-15-2010 03:41 AM
Using Custom Metadata in Save Template EJvdH Calibre 1 07-02-2010 06:06 AM
Accessories Decalgirl Kindle 2 custom skin template srmalloy Amazon Kindle 6 04-09-2010 09:55 PM
Donations for Custom Recipes ddavtian Calibre 5 01-23-2010 04:54 PM
Help understanding custom recipes andersent Calibre 0 12-17-2009 02:37 PM


All times are GMT -4. The time now is 06:30 PM.


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