![]() |
#526 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I managed to figure this, perhaps a bit clumsily -- also changed some of the reference names to be a bit clearer
Code:
program: genre = $#subjects; new_colls = strcat( ## if $$#purchasecost == '0.00' then 'Freebies,' fi, if 'Omnibus' in $#admintags then 'Omnibuses,' fi, if 'overdrive' in approximate_formats() && !$purchasesource then 'Loans,' fi, if $#booktype=='Fanfiction' then list_re($tags, ',', '^Fanfiction.(.*)$', 'Fanfiction: \1,') fi, if 'public domain' inlist $#admintags then 'Public Domain,' fi, if '^Cozy Mystery$' inlist genre then 'Cozy Mysteries,' fi, if '^Horses$' inlist genre then 'Horses,' fi, if 'Folktales & Mythology' inlist genre then 'Folktales & Mythology,' fi, if '^Science Fiction$' inlist genre then 'Science Fiction,' fi, if '^(Fantasy|Paranormal)$' inlist genre then 'Fantasy & Paranormal,' fi, ); if new_colls == '' then existing_colls = $#kobocoll fi; if new_colls then existing_colls = list_difference($#kobocoll, $#booktype, ',') fi; if new_colls == '' then new_colls = strcat($#booktype, ',') fi; merged_colls = list_union(new_colls, existing_colls, ','); new_colls generates a set of new collections with the strcat existing_colls is taken from the existing #kobocoll value. If new_colls exists, it removes booktype from the list If new_colls doesn't exist, it sets it to #booktype merged_colls combines new_colls and existing_colls. Last edited by ownedbycats; 03-12-2023 at 07:29 AM. |
![]() |
![]() |
![]() |
#527 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,460
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: ... if !new_colls then existing_colls = $#kobocoll; new_colls = $#booktype else existing_colls = list_difference($#kobocoll, $#booktype, ',') fi; merged_colls = list_union(new_colls, existing_colls, ','); |
|
![]() |
![]() |
![]() |
#528 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
A bit easier to understand, too. Thanks
![]() |
![]() |
![]() |
![]() |
#529 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
New question: I have an enumerated column, #purchasesource. Four of these have related identifiers that often are downloaded during metadata downloads:
Amazon - amazon Baen - baen Barnes & Noble - barnesnoble Kobo - kobo I prefer to have the identifier only for the store I got it from. So I made this template to remove the extra ones: 1. I have a book with #purchasesource set to "Kobo." After a metadata download, the book has goodreads, isbn, barnesnoble, and kobo identifiers. 2. Purchasesource is not Barnes & Noble, so the second if-then removes the barnesnoble identifier. 3. Purchasesource is Kobo, so the third if-then doesn't remove the Kobo identifier. 4. It doesn't remove the goodreads or isbn identifiers. If I run the same template on a book that has no #purchasesource, it removes all four of them. If no identifiers are removed, it just returns the original list. Code:
program: if !$#purchasesource=="Amazon" && select($identifier, 'amazon') then list_difference ($identifier, strcat('amazon:', select($identifier, 'amazon')), ',') elif !$#purchasesource=="Barnes & Noble" && select($identifier, 'barnesnoble') then list_difference ($identifier, strcat('barnesnoble:', select($identifier, 'barnesnoble')), ',') elif !$#purchasesource=="Kobo" && select($identifier, 'kobo') then list_difference ($identifier, strcat('kobo:', select($identifier, 'kobo')), ',') elif !$#purchasesource=="Baen" && select($identifier, 'baen') then list_difference ($identifier, strcat('baen:', select($identifier, 'baen')), ',') fi ![]() Last edited by ownedbycats; 03-25-2023 at 10:47 AM. |
![]() |
![]() |
![]() |
#530 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,460
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: def do_one(ids, check_value, select_identifier): si = select($identifier, select_identifier); if !$#purchasesource==check_value && si then return list_difference (ids, strcat(select_identifier, si), ',') fi; return $ids fed; ids = do_one($identifiers, "Amazon",'amazon'); ids = do_one(ids, "Barnes & Noble", 'barnesnoble'); ids = do_one(ids, "Kobo", 'kobo'); ids = do_one(ids, "Baen", 'baen') |
|
![]() |
![]() |
![]() |
#531 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I had to change line 10 to use $identifiers but it seems to work
![]() |
![]() |
![]() |
![]() |
#532 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,460
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#533 | |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 166
Karma: 727278
Join Date: Dec 2022
Location: Not in an English speaking country
Device: (Too many) Kobo(s)
|
I feel there's an easy solution to this, but I can't find it on my own, so I need a bit of help.
I have a column (genre) that I use as a hierarchical tag. Some examples of data I have in this column are: Fiction.Classics.English Literature Fiction.Classics.French Literature Fiction.Historical Novel.Country: India Fiction.Fantasy Then I have another column (genre_list) that separates genres using: Quote:
Now, I would like to have another column that excludes some items from genre_list. The items I would like to remove are the ones matching the pattern: "xxxx Literature" and "Country: xxxx" I know I can use list_difference to exclude values, but the list with the excluded values is compared term by term. Is there a way to do so without having to list beforehand all occurrences of Country: xxxx, Xxxx Literature, but using the pattern? ![]() ![]() ![]() |
|
![]() |
![]() |
![]() |
#534 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,460
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: a = list_re($#genre, ',', '^(.* Literature|Country: .*)$', ''); list_difference($#genre, a, ',') |
|
![]() |
![]() |
![]() |
#535 | |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 166
Karma: 727278
Join Date: Dec 2022
Location: Not in an English speaking country
Device: (Too many) Kobo(s)
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#536 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
While trying to set up the template in #530 I found a failure point that I'm surprised I managed to miss:
Code:
program: if !$#purchasesource=="Amazon" && select($identifier, 'amazon') then list_difference ($identifier, strcat('amazon:', select($identifier, 'amazon')), ',') elif !$#purchasesource=="Barnes & Noble" && select($identifier, 'barnesnoble') then list_difference ($identifier, strcat('barnesnoble:', select($identifier, 'barnesnoble')), ',') elif !$#purchasesource=="Kobo" && select($identifier, 'kobo') then list_difference ($identifier, strcat('kobo:', select($identifier, 'kobo')), ',') elif !$#purchasesource=="Baen" && select($identifier, 'baen') then list_difference ($identifier, strcat('baen:', select($identifier, 'baen')), ',') fi ![]() |
![]() |
![]() |
![]() |
#537 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,460
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
NB: The template in #530 doesn't have the problem. For completeness, here is the version corrected for the error you mentioned in #531. Code:
program: def do_one(ids, check_value, select_identifier): si = select(ids, select_identifier); if !$#purchasesource==check_value && si then return list_difference (ids, strcat(select_identifier, si), ',') fi; return ids fed; ids = do_one($identifiers, "Amazon",'amazon'); ids = do_one(ids, "Barnes & Noble", 'barnesnoble'); ids = do_one(ids, "Kobo", 'kobo'); ids = do_one(ids, "Baen", 'baen') |
|
![]() |
![]() |
![]() |
#538 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I can't figure out what's going on -- it's failing on this one specific book. It has no #purchasesource but adding one doesn't seem to work.
|
![]() |
![]() |
![]() |
#539 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,460
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Try this: Code:
return list_difference (ids, strcat(select_identifier, ':', si), ',') An alternate change that is a bit slower is Code:
return list_difference (ids, select(ids, select_identifier), ',') |
|
![]() |
![]() |
![]() |
#540 |
Custom User Title
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,050
Karma: 75568269
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
That works
![]() Question: Rarely when updating a saved template, I get an error about it being duplicated when using it elsewhere. This disappears upon restart. Is this a known glitch? |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library Management: various questions not worth their own thread | ownedbycats | Library Management | 229 | Today 06:41 PM |
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates | Boilerplate4U | Development | 13 | 07-07-2020 02:35 AM |
Questions on Kobo [Interfered with another thread topic] | spdavies | Kobo Reader | 8 | 10-12-2014 11:37 AM |
[OLD Thread] Some questions before buying the fire. | darthreader13 | Kindle Fire | 7 | 05-10-2013 09:19 PM |
Thread management questions | meme | Feedback | 6 | 01-31-2011 05:07 PM |