|
|
Thread Tools | Search this Thread |
09-14-2013, 01:25 PM | #1 |
Guru
Posts: 787
Karma: 1575310
Join Date: Jul 2009
Device: Moon+ Pro
|
Custom column returns value based on value of another custom column?
I'm trying to expand the ratings. Rather than 1-5 stars I want text representing 0-10 values:
0=Unread (Blank also indicates unread) 1=Started but so bad I didn't finish reading it 2=Poor, but finished reading it 3=Almost OK 4=OK 5=Better than OK 6=Almost good 7=Good 8=Better than good 9=Almost great 10=Great As I see it I'll need 2 columns, a numerical column for sorting & a text column to display the text ratings. I'm pretty sure the text column will be what Calibre help calls a composite column but I can't figure out the formula. I think it will be some variation of the lookup function but I'm not sure what. Basically I'm unsatisfied with the built-in ratings because each increment seems, to me, to be a significant change from the previous/next-and I often have trouble deciding. Expanding it allows overlap-it doesn't really matter whether I rate a book 8 or 9 as the meanings are close. That makes it easier for me plus I simply prefer text values to numeric (even when numeric is expressed in number of stars it's still numeric). In a spreadsheet I can do this easily. The problem is that I'm not very familiar with either Python or RegEx. I'm trying to learn but it's going slowly. Maybe it would go faster if I had more time to spend on it but time is what it is-so I'm asking for help. Thanks. |
09-14-2013, 01:44 PM | #2 |
Grand Sorcerer
Posts: 12,029
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Try something like this template in general program mode, with #myint changed to the appropriate lookup key.
Code:
program: t = "Unread, Started but so bad I didn't finish reading it, Poor but finished reading it,"; t = strcat(t, "Almost OK, OK, Better than OK, Almost good, Good,"); t = strcat(t, "Better than good, Almost great, Great"); index = ifempty(field('#myint'), 0); val = list_item(t, index, ','); cmp(index, 10,val, val, 'Huh?') |
Advert | |
|
09-14-2013, 02:15 PM | #3 |
Guru
Posts: 787
Karma: 1575310
Join Date: Jul 2009
Device: Moon+ Pro
|
Thanks greatly! I was way off on the wrong track-and I even understand the program except for the reason for the last line. I assume that's an error trap in case I stupidly enter a rating higher than 10? (I haven't found a way to limit the input in an integer column but don't consider that critical since I'm the only one that'll be using this.)
Also, is there a limit to the length of an argument? I noticed you broke the list up into 3 sections & then concatenated them. Was that just for readability? I'll probably reduce the length of some of the items (e.g. 'Unfinished' rather than 'so bad I couldn't finish it') when I actually implement this. Thanks again. |
09-14-2013, 03:24 PM | #4 | ||
Grand Sorcerer
Posts: 12,029
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
|
||
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using "Build column from other column" custom-column type | HFC3 | Library Management | 3 | 07-07-2013 04:11 AM |
Custom yes/no column built from long text column | Philantrop | Library Management | 7 | 03-23-2013 08:44 PM |
how to move value(s) of tag column to a custom made column | zoorakhan | Library Management | 0 | 12-08-2012 04:53 AM |
custom date column from two state column | Dopedangel | Library Management | 7 | 01-03-2012 09:20 AM |
Can custom book data be displayed in a custom column? | kiwidude | Development | 9 | 03-02-2011 06:35 AM |