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 07-14-2022, 05:25 PM   #1
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
Renaming items on a list

Quote:
Originally Posted by chaley View Post

Code:
program:
	a = list_intersection($ao3tags, 'tram, train, bus, ferry', ',');
	list_union($#genre, a, ',')
I'm assuming one could use something similar to replace 'tram, train, bus, ferry' by lets say 'public transport' using the template functions. Still trying to wrap my head around this. But it looks very useful for what I'm trying to do. Because when you have quite a few items you want to amend it gets rather frustrating to use the built in search and replace option.

Also I'm not sure I understand how to use the template scope properly to search and then get the "template output is calibre search' using listed items.

I sort of got it to work, but I'm not sure I use this correctly:
Code:
#tags_show:"=tram" or
#tags_show:"=bus"
I'm looking for something like:
Code:
search(#tags_show, ('tram, bus')
I used to regex shit like this while downloading, but my personal.ini in FFF got way to long and it slowed my download immensely. Doing this afterwards makes more sense. Using action chains give me more control.
ackomb is offline   Reply With Quote
Old 07-16-2022, 11:52 AM   #2
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
So I've been fiddling with it some more, and figured out I can use the same principle as this

Code:
program:
	a = list_intersection($ao3tags, 'tram, train, bus, ferry', ',');
	list_union($#genre, a, ',')
but instead use 're' in the place of list-union

Code:
program:
        a = list_intersection($#show, 'Ferry, Bus', ',');
        re($#show, a , 'Vehicles, Public Transport')
The issue lies within the following, if a story has the following
tags: Bus, Car, Ferry, Ferry Terminal,
the result will be:
tags: Vehicles, Public Transport, Vehicles, Public Transport Terminal, Red, Car


The tag 'Ferry Terminal' will result in 'Public Transport Terminal'.
I figured the reason is because it is a match but not an exact match.
I've tried several options trying to get an exact match using ^ and $ like with regex but I keep getting errors

Can anyone point me in the right direction, because the Calibre Manual is not getting me anywhere on this one.
ackomb is offline   Reply With Quote
Advert
Old 07-16-2022, 12:52 PM   #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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ackomb View Post
So I've been fiddling with it some more, and figured out I can use the same principle as this

Code:
program:
	a = list_intersection($ao3tags, 'tram, train, bus, ferry', ',');
	list_union($#genre, a, ',')
but instead use 're' in the place of list-union

Code:
program:
        a = list_intersection($#show, 'Ferry, Bus', ',');
        re($#show, a , 'Vehicles, Public Transport')
The issue lies within the following, if a story has the following
tags: Bus, Car, Ferry, Ferry Terminal,
the result will be:
tags: Vehicles, Public Transport, Vehicles, Public Transport Terminal, Red, Car


The tag 'Ferry Terminal' will result in 'Public Transport Terminal'.
I figured the reason is because it is a match but not an exact match.
I've tried several options trying to get an exact match using ^ and $ like with regex but I keep getting errors

Can anyone point me in the right direction, because the Calibre Manual is not getting me anywhere on this one.
I am lost. What are you trying to do? Is this the problem you talked about 2 posts back where you want to replace any/all of 'tram, train, bus, ferry' by one instance of 'public transport'? If so, what is the list_intersection for? It returns a list that contains bus and/or ferry, if these two items exist in $#show. The order is not guaranteed.

Lets say you are trying to replace 'Ferry' or 'Starship' with 'Vehicle', and 'Bus' with 'Public Transport'. This does it.
Code:
program:
	sample_input = 'Bus, Car, Starship, Ferry, Ferry Terminal, Alien Spacecraft';

	output = list_re_group(
		sample_input, ',', '.',
		'(^bus$)|(^ferry$|^starship$)', 'Public Transport', 'Vehicle')
The output of the template is
Code:
Public Transport, Car, Vehicle, Ferry Terminal, Alien Spacecraft
There are other ways to do it, including processing the list with a 'for' statement then checking the items.

One thing to know: re() is nearly useless when dealing with lists. It doesn't deal with list order, instead treating the list as text. In certain situations such as my example above you can use list_re_group() so that the regular expression is applied to each list item, not the list itself.

If this discussion will go on for a while then it should get moved to its own thread. I can do that.
chaley is offline   Reply With Quote
Old 07-16-2022, 01:09 PM   #4
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Moderator Notice
Discussion moved to its own thread
chaley is offline   Reply With Quote
Old 07-16-2022, 01:24 PM   #5
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
This is a way to do the same example using a for loop. It might be easier to read and understand.
Code:
program:
	sample_input = 'Bus, Car, Starship, Ferry, Ferry Terminal, Alien Spacecraft';

	output = '';
	for item in sample_input:
		if  	  item == 'bus' then ni = 'Public Transport'
			elif item == 'ferry' then ni = 'Vehicle'
			elif item == 'starship' then ni = 'Vehicle'
			else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_remove_duplicates(output, ',')
The output is
Code:
Public Transport, Car, Vehicle, Ferry Terminal, Alien Spacecraft
You can sort the list if you want with
Code:
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
Now the output is
Code:
Alien Spacecraft, Car, Ferry Terminal, Public Transport, Vehicle
chaley is offline   Reply With Quote
Advert
Old 07-16-2022, 01:38 PM   #6
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
Template Functionality

@Chaley,

Thanks for the quick reply, I'm trying to learn my may around with template functions and the best way for me is to learn by trial and error and I try to learn from previous posts or the Calibre manual but I'm missing some basic examples to make me understand sometimes and some of the posts are too advanced for me to understand for now. I even started some free online phyton code writing course to improve my understanding of the examples on this forum. So more questions are likely tbh, if this is not the place but a separate thread is, then by all means move it, I wouldn't know how to (if allowed at all).

To answer your question, yes this was a continuation of my post on the 14th. I thought I had figured it out, but guess not .

I do not care about the order of the tags, but good to know it exists. Obviously the data is bogus, I was trying to change 2 out of the 4 tags by matching the whole string while keeping the rest in tact. Perhaps my example was not so clear since I also had two tags as the outcome.

But for clarity another example people use ship names in characters for example 'Clexa' and 'Princess Commander' the character names are Clarke and Lexa, so I'm trying to convert these lists of ship names into separate characters. Since AO3 keeps inventing new tags I occasionally dump the new / left over data into excel and figure out which I want to keep and change and then auto convert them into strings that I copy back adding into an new/or existing line in the action chains. There are built in options, but the Search and Replace box was becoming to small and unreadable and single field edit annoying because you can not amend you list but in stead have to select it all over again. Which is why I was looking into these template functions to begin with.
ackomb is offline   Reply With Quote
Old 07-16-2022, 02:14 PM   #7
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
@ackomb: If I came across as critical or negative then I am sorry. I really like it when people try and I am glad to help. We both end up learning something.

Also, the posts are already moved to a new thread. It is in Library Management now. The reason: I suspect that we might go on at length about stuff that is only peripherally related to action chains. It also makes the info easier to find.

Given your Clexa etc example I suspect that the for loop version will be easiest for you to maintain over time. It is more clear what is being changed to what. It can be slightly improved to better handle several variants going to the same result, which might be useful as the list of conditions gets longer. Example:
Code:
program:
	sample_input = 'Bus, Car, Starship, Ferry, Ferry Terminal, Alien Spacecraft';

	output = '';
	for item in sample_input:
		if '^bus$' in item then ni = 'Public Transport'
		elif '^ferry|starship$'in item then ni = 'Vehicle'
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_remove_duplicates(output, ',')
The template 'in' operator checks if a regex matches the value. This permits checking in one expression for several values that map to a single result.

On the other hand I can imagine using excel to generate the template replacement expressions, which could make the '==' form better.

I have in the past considered writing a 'list_map() function that would take a series of pairs: (list_of_terms_to_change, result_value). Example:
Code:
map(src_list, separator,
    'ferry, boat, hydroplane', 'watercraft',
    'car, auto, truck', 'vehicle',
    ...)
I will think about that, working out whether it adds enough value to be worth the effort.

EDIT: Another option is to supply a template interface to the existing tag mapper (Preferences / Adding books / Adding actions / Rules to filter tags). The function would take a series of lists that each define a mapper rule, then apply those rules. The benefit here is that the code exists and is maintained. The downside is that rules are a bit more complicated to express.

Last edited by chaley; 07-16-2022 at 02:27 PM.
chaley is offline   Reply With Quote
Old 07-16-2022, 03:10 PM   #8
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
Quote:
Originally Posted by chaley View Post
@ackomb: If I came across as critical or negative then I am sorry. I really like it when people try and I am glad to help. We both end up learning something.
No worries, I didn't think you were critical or negative, just confused as you said. I figured at some point I would get OFF Topic to much but by then I started already and didn't know how to move it.

So I guess my code will go from here adding elif's when needed
Code:
program:
	output = '';
	for item in $#cumstom_column:
		if  	  item == 'bus' then ni = 'Public Transport'
		elif  	  item == 'car' then ni = 'Public Transport'
		elif  	  item == 'ferry' then ni = 'Public Transport'
		elif  	  item == 'red' then ni = 'Public Transport'
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')

Input:
Code:
Bus, Car, Ferry, Ferry Terminal, Red
Result Output:
Code:
Ferry Terminal, Public Transport
Originally I thought that the list_intersection was a way to create a list of items you wanted to use in the next line as a val the way 'a' worked in list_union in:

Code:
program:
	a = list_intersection($#cumstom_column_a, 'tram, train, bus, ferry', ',');
	list_union($#cumstom_column_b, a, ',')
I'm wondering though if there is a way to make it more like this:

Code:
program:
	list = 'bus, car, ferry, red'
	output = '';
	for item in $#cumstom_column:
		if  	  item == in list then ni = 'Public Transport'
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
Also, are there limitations to the elif statements within one template? I've had Calibre crash sometimes running an action chain, so I'm chopping them up in bits and pieces anyway, just want to know the limitations.
ackomb is offline   Reply With Quote
Old 07-16-2022, 04:31 PM   #9
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ackomb View Post
I'm wondering though if there is a way to make it more like this:

Code:
program:
	list = 'bus, car, ferry, red'
	output = '';
	for item in $#cumstom_column:
		if  	  item == in list then ni = 'Public Transport'
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
Yes, but the syntax is different from what you wrote. Here is your template, corrected.
Code:
program:
	sample_input = 'bus, carpool, ferry, redbus';
	list = 'bus, car, ferry, red';
	output = '';

# Change $#custom_column to sample_input so the value exists, avoiding an error.
	for item in sample_input:
		if ('^' & item & '$') inlist list then ni = 'Public Transport'
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
Quote:
Also, are there limitations to the elif statements within one template? I've had Calibre crash sometimes running an action chain, so I'm chopping them up in bits and pieces anyway, just want to know the limitations.
There is recursion in parsing so the default limit to elifs is 1000. Do you think you might go over that?
chaley is offline   Reply With Quote
Old 07-16-2022, 05:42 PM   #10
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
Quote:
Originally Posted by chaley View Post
There is recursion in parsing so the default limit to elifs is 1000. Do you think you might go over that?
I should hope not , but better safe then sorry right?

Thank you for your help, right now I'm to tired to think straight, so I will try to implement it tomorrow and see how far I will get. I'm beginning to understand more and more.

ackomb is offline   Reply With Quote
Old 07-16-2022, 05:56 PM   #11
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
Posts: 13,511
Karma: 78910202
Join Date: Nov 2007
Location: Toronto
Device: Libra H2O, Libra Colour
Could you also use a switch statement, rather than lots of elif statements?

Sent from my Pixel 4a using Tapatalk
PeterT is offline   Reply With Quote
Old 07-16-2022, 06:04 PM   #12
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by PeterT View Post
Could you also use a switch statement, rather than lots of elif statements?
Yes. Good point. Switch is effectively a series of "if pattern matches value then result".

One difference is that the chain of elifs stops on a match while a switch evaluates all the pairs then picks the first that matches. The switch is slower if there are matches. In most contexts that probably doesn't matter.
chaley is offline   Reply With Quote
Old 07-17-2022, 06:29 AM   #13
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
Quote:
Originally Posted by chaley View Post
Yes, but the syntax is different from what you wrote. Here is your template, corrected.
This is not me trying to be a being a wise ass but I've tested this but it's not quite working the way I wanted.
Let say that my custom_column named #ao3show contains the following items:
Code:
Bus, Car, Ferry, Ferry Terminal, Red
I've then entered your code as follows:
Code:
program:
	sample_input = 'Bus, Car, Ferry, Ferry Terminal';
	list = 'bus, ferry';
	output = '';

# Change $#custom_column to sample_input so the value exists, avoiding an error.
	for item in sample_input:
		if ('^' & item & '$') inlist list then ni = 'Public Transport'
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
The outcome is:
Code:
Car, Ferry Terminal, Public Transport
Red is gone completely, not replaced just gone.
Whereas if I replace the list sample_input with the actual column and add a 2nd list with tags I want to remove like this:

Code:
program:
	list = 'bus, ferry';
	list2 = 'Car';
	output = '';

# Change $#custom_column to sample_input so the value exists, avoiding an error.
	for item in $#ao3show:
		if ('^' & item & '$') inlist list then ni = 'Public Transport'
		elif ('^' & item & '$') inlist list2 then ni = ' '
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
The outcome is:
Code:
Ferry Terminal, Public Transport, Red
I would then use the other piece of code you helped me with to transfer "Public Transport" from #ao3show to #show, the latter only containing tags I want to keep which would leave me with the tags not mentioned in 'list' or 'list2'. This would allow me to run the action after downloading and then check the remaining tags to see whether or not I find them useful.
Attached Thumbnails
Click image for larger version

Name:	ScreenShotTemplateTester.jpg
Views:	119
Size:	40.4 KB
ID:	195078  

Last edited by ackomb; 07-17-2022 at 06:30 AM. Reason: I attached the wrong screenshot, Car should not be in there
ackomb is offline   Reply With Quote
Old 07-17-2022, 06:46 AM   #14
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ackomb View Post
This is not me trying to be a being a wise ass but I've tested this but it's not quite working the way I wanted.
Let say that my custom_column named #ao3show contains the following items:
Code:
Bus, Car, Ferry, Ferry Terminal, Red
I've then entered your code as follows:
Code:
program:
	sample_input = 'Bus, Car, Ferry, Ferry Terminal';
	list = 'bus, ferry';
	output = '';

# Change $#custom_column to sample_input so the value exists, avoiding an error.
	for item in sample_input:
		if ('^' & item & '$') inlist list then ni = 'Public Transport'
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
The outcome is:
Code:
Car, Ferry Terminal, Public Transport
Red is gone completely, not replaced just gone.
That is because 'Red' is not in the sample input.
Quote:
Whereas if I replace the list sample_input with the actual column
That is what I intended you to do -- to use live data I don't have.
Quote:
and add a 2nd list with tags I want to remove like this:

Code:
program:
	list = 'bus, ferry';
	list2 = 'Car';
	output = '';

# Change $#custom_column to sample_input so the value exists, avoiding an error.
	for item in $#ao3show:
		if ('^' & item & '$') inlist list then ni = 'Public Transport'
		elif ('^' & item & '$') inlist list2 then ni = ' '
		else ni = item
		fi;
		output = output & ',' & ni
	rof;
	output = list_sort(list_remove_duplicates(output, ','), 0, ',')
The outcome is:
Code:
Ferry Terminal, Public Transport, Red
That is a good way to remove elements. It eliminates the need for list_intersection().

FWIW: The comment Change ... is now meaningless because you are using live data that I don't have.
Quote:
I would then use the other piece of code you helped me with to transfer "Public Transport" from #ao3show to #show, the latter only containing tags I want to keep which would leave me with the tags not mentioned in 'list' or 'list2'. This would allow me to run the action after downloading and then check the remaining tags to see whether or not I find them useful.
Good. I hope it works.
chaley is offline   Reply With Quote
Old 08-11-2022, 09:40 AM   #15
ackomb
Zealot
ackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura aboutackomb has a spectacular aura about
 
Posts: 106
Karma: 4486
Join Date: Mar 2020
Location: Netherlands
Device: i-pad
So far so good, I've been tinkering with all this for a while but I've run into something that has me stumped.

Withing FFF there is this option 'sort_ships' which alphabetically sorts the characters within a ship.

Now I want to sort them after I changed them, how would I program such a thing?
ackomb is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Jumping to items in book list without activating keyboard shortcuts ownedbycats Library Management 7 01-26-2021 03:22 PM
Commas Following List Items TheArtfulDodger Library Management 3 07-15-2018 06:33 PM
All my documents from "My Items" list on Kindle Touch disappeared kinkle Kindle Developer's Corner 33 03-02-2016 02:42 PM
Recipe for Safari "Reading List" unread items anoved Recipes 6 03-19-2013 01:21 PM
Cant remove items from "Im Reading" list fictionaddiction Kobo Reader 1 06-21-2011 12:11 PM


All times are GMT -4. The time now is 01:45 PM.


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