Quote:
Originally Posted by Noughty
Everything is spelled correctly as far as I can tell.
They are composite columns using code like this:
Code:
program:
list_union(
list_intersection(field('tags'), 'values listed, ','),
list_intersection(field('#shelf'), 'values listed', ','),
',')
It deletes Short, delete but not custom columns. I guess because they are custom. All values are with first letter uppercase, others lowercase.
|
Try this program. Replace the Program Code of your otherts function with the code above.
Code:
def evaluate(self, formatter, kwargs, mi, locals):
# Tags is a multiple text field, so it is already split
tags = set(mi.get('tags', []))
# Shelf is a composite column, so we must split it
shelf = set([l.strip() for l in mi.get('#shelf', "").split(',')])
# Genre is a composite column, so we must split it
genre = set([l.strip() for l in mi.get('#genre', "").split(',')])
# Mode is a composite column, so we must split it
mode = set([l.strip() for l in mi.get('#mode', "").split(',')])
# Character is a composite column, so we must split it
charac = set([l.strip() for l in mi.get('#character', "").split(',')])
st = tags | shelf
gmc = set(['Short', 'delete']) | genre | mode | charac
res = st - gmc
return ', '.join(res)
Quote:
|
Maybe I could just paste all these values from these into python code like 'short, delete' are? The ones I want to remove.
|
If you know the list and it isn't too long, that isn't a bad solution at all.
Quote:
|
What function I would use in python to write the values I want to keep, not add. Like extract only those values? I'll try to write it myself using your example. I just need a function so I could use it for genre, character,mode columns. It would be more efficient as far as I understand.
|
If I understand your question, it would be something like:
Code:
def evaluate(self, formatter, kwargs, mi, locals):
# Tags is a multiple text field, so it is already split
tags = set(mi.get('tags', []))
# Shelf is a composite column, so we must split it
shelf = set([l.strip() for l in mi.get('#shelf', "").split(',')])
# items to remove from the result
to_remove = set(['Short', 'delete', 'foo', 'bar', somethingElse',
'andSoOn', 'until I get tired', 'of adding things'])
# combine the two fields containing items we might want to keep.
st = tags | shelf
# now remove the items we don't want in the result
res = st - to_remove
return ', '.join(res)