[tw5] Re: How to create a new field and translate multiple values with a dictionary?
On Friday, December 11, 2020 at 7:05:32 AM UTC-8 Harry wrote: > when I click the button, nothing changes. I wonder if this is because my > birth_year field also has "na" as a value, I changed all na to 0, but the > button still does not work. > <$button> assign retired > <$list filter="[has[birth_year]]"> ><$list > filter="[get[birth_year]compare:integer:lt[1948]then!c_status[dead]!c_status[purged]]"> > <$action-setfield c_status="retired" /> > > > > A field value of "na" is equivalent to "0". I tried the above code on TiddlyWiki.com, providing it with a tiddler named "test", containing a "birth_year" field containing "na". After pressing the button, the "test" tiddler had a new "c_status" field added, containing a value of "retired". Note that to see this field and value, you have to edit the "test" tiddler. > I then tried the following code to create a list, but the tiddler still > shows nothing. I wonder if you have any idea about what might be wrong with > my dataset? Many thanks! > <$list filter="[has[birth_year]]"> > <$list > filter="[get[birth_year]compare:number:gteq[1]compare:number:lteq[1948]]"> > <> > > > You left off the "then" syntax that follows the compare. Without this, the result of the filter is the value that you get[...] from the birth_year field, rather than the title of the matching tiddler. Also, your first compare is "gteq[1]", so this would not match tiddlers where the "birth_year" field contains "0" (or "na"). If you change the filter to: <$list filter="[get[birth_year]compare:number:gteq[0]compare:number:lteq[1948]then]"> it will show tiddler titles for all tiddlers with a non-blank "birth_year" field, even those with a value of "0" or "na". enjoy, -e -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/a457d3e7-952f-4109-aef1-5d9b8802a43en%40googlegroups.com.
[tw5] Re: How to create a new field and translate multiple values with a dictionary?
Thanks Eric! may I ask you to also look into the question in my first post? ( create a new field using a dictionary tiddler) Also I tried the code you provided, really learned a lot on the compare operator.But when I click the button, nothing changes. I wonder if this is because my birth_year field also has "na" as a value, I changed all na to 0, but the button still does not work. <$button> assign retired <$list filter="[has[birth_year]]"> <$list filter="[get[birth_year]compare:integer:lt[1948]then!c_status[dead]!c_status[purged]]"> <$action-setfield c_status="retired" /> I then tried the following code to create a list, but the tiddler still shows nothing. I wonder if you have any idea about what might be wrong with my dataset? Many thanks! <$list filter="[has[birth_year]]"> <$list filter="[get[birth_year]compare:number:gteq[1]compare:number:lteq[1948]]"> <> 在2020年12月11日星期五 UTC-5 上午5:54:48 写道: > Here's some sample filter logic for each of the conditions you want: > > On Thursday, December 10, 2020 at 8:52:42 PM UTC-8 Harry wrote: > >> I want to filter all entries born before 1948 (in the birth_year field) >> who has not died or been purged (in the c_status field), and assign them >> value "retired". >> > > *birth_date < 1948 and not c_status=dead and not c_status=purged* > <$button> assign retired > <$list filter="[has[birth_year]]"> ><$list > filter="[get[birth_year]compare:integer:lt[1948]then!c_status[dead]!c_status[purged]]"> > <$action-setfield c_status="retired" /> > > > > > I would also appreciate general guidance on filtering field value of a >> certain numeric range (say greater than 1952, or between 1936 and 1978) >> > > *birth_date > 1952* > <$list filter="[has[birth_year]]"> ><$list > filter="[get[birth_year]compare:integer:gt[1952]then]"> > <> > > > > *birth_date between 1936 and 1978 (inclusive)* > <$list filter="[has[birth_year]]"> ><$list > filter="[get[birth_year]compare:integer:gteq[1936]compare:integer:lteq[1978]then]"> > <> > > > > >> or value of a particular vector (say contains either >> 1,3,8,16,33,47,287,1345, etc, >> > > *somefield contains any of 1,3,8,16,33,47,287,1345,* > <$list filter="[has[somefield]]"> ><$list filter="[enlist[1 3 8 16 33 47 287 1345 > ]match{!!somefield}then]"> > <> > > > > enjoy, > -e > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/699d3dbd-9db0-491b-8f79-59ca51a8e006n%40googlegroups.com.
[tw5] Re: How to create a new field and translate multiple values with a dictionary?
Mohammed's tiddly commander thing also allows batch operations. I'll try and dig out the link when I get chance of no one beats me to it. On Friday, 11 December 2020 at 10:54:48 UTC Eric Shulman wrote: > Here's some sample filter logic for each of the conditions you want: > > On Thursday, December 10, 2020 at 8:52:42 PM UTC-8 Harry wrote: > >> I want to filter all entries born before 1948 (in the birth_year field) >> who has not died or been purged (in the c_status field), and assign them >> value "retired". >> > > *birth_date < 1948 and not c_status=dead and not c_status=purged* > <$button> assign retired > <$list filter="[has[birth_year]]"> ><$list > filter="[get[birth_year]compare:integer:lt[1948]then!c_status[dead]!c_status[purged]]"> > <$action-setfield c_status="retired" /> > > > > > I would also appreciate general guidance on filtering field value of a >> certain numeric range (say greater than 1952, or between 1936 and 1978) >> > > *birth_date > 1952* > <$list filter="[has[birth_year]]"> ><$list > filter="[get[birth_year]compare:integer:gt[1952]then]"> > <> > > > > *birth_date between 1936 and 1978 (inclusive)* > <$list filter="[has[birth_year]]"> ><$list > filter="[get[birth_year]compare:integer:gteq[1936]compare:integer:lteq[1978]then]"> > <> > > > > >> or value of a particular vector (say contains either >> 1,3,8,16,33,47,287,1345, etc, >> > > *somefield contains any of 1,3,8,16,33,47,287,1345,* > <$list filter="[has[somefield]]"> ><$list filter="[enlist[1 3 8 16 33 47 287 1345 > ]match{!!somefield}then]"> > <> > > > > enjoy, > -e > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/eca48727-c77e-4668-8490-3a60f2807cd3n%40googlegroups.com.
[tw5] Re: How to create a new field and translate multiple values with a dictionary?
Here's some sample filter logic for each of the conditions you want: On Thursday, December 10, 2020 at 8:52:42 PM UTC-8 Harry wrote: > I want to filter all entries born before 1948 (in the birth_year field) > who has not died or been purged (in the c_status field), and assign them > value "retired". > *birth_date < 1948 and not c_status=dead and not c_status=purged* <$button> assign retired <$list filter="[has[birth_year]]"> <$list filter="[get[birth_year]compare:integer:lt[1948]then!c_status[dead]!c_status[purged]]"> <$action-setfield c_status="retired" /> I would also appreciate general guidance on filtering field value of a > certain numeric range (say greater than 1952, or between 1936 and 1978) > *birth_date > 1952* <$list filter="[has[birth_year]]"> <$list filter="[get[birth_year]compare:integer:gt[1952]then]"> <> *birth_date between 1936 and 1978 (inclusive)* <$list filter="[has[birth_year]]"> <$list filter="[get[birth_year]compare:integer:gteq[1936]compare:integer:lteq[1978]then]"> <> > or value of a particular vector (say contains either > 1,3,8,16,33,47,287,1345, etc, > *somefield contains any of 1,3,8,16,33,47,287,1345,* <$list filter="[has[somefield]]"> <$list filter="[enlist[1 3 8 16 33 47 287 1345 ]match{!!somefield}then]"> <> enjoy, -e -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/ceb8ca50-9ca2-4024-adaa-3d028cc8d0f6n%40googlegroups.com.
[tw5] Re: How to create a new field and translate multiple values with a dictionary?
Another novice question: I want to filter all entries born before 1948 (in the birth_year field) who has not died or been purged (in the c_status field), and assign them value "retired". The following code I created apparently contains error. I would also appreciate general guidance on filtering field value of a certain numeric range (say greater than 1952, or between 1936 and 1978) or value of a particular vector (say contains either 1,3,8,16,33,47,287,1345, etc, do I need to name another tiddly for reference? Kind of confused after some research) <$button> assign retired <$list filter="[field[birth_year]<<1948]-[field[c_status]=dead]-[field[c_status]=purged]"> <$action-setfield $field="c_status" $value="retired" /> 在2020年12月10日星期四 UTC-5 下午10:01:17 写道: > Hi, > > I have a tiddlywiki with multiple entries. I now want to assign a unique > field value for every entry so that I can sort them in a particular way. Is > there a way that I can do this with button or other batch orders. I > searched and found something of creating a dictionary. > > Say I select all entries with birthdays entered. > <$list filter="[has:field[birth_year]]"> > > Then I want to create a new field called "rankcode" for each entry, > translating their titles to a unique 6-digit code in their, using the > dictionary below > > John Smith (Reno):BCD-75A > John Adams:5GH-6GB > Brian Kim:67A-300 > Cris Stuart (NV):3ZH-UV5 > > I'd appreciate help on how to do this. I tried $action-setfield to assign > one single value to one entry at a time, but don't know how to do this en > masse using sth like a dictionary. Many thanks! > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b926ee2c-4bc0-4cb1-9f7c-dcb766967691n%40googlegroups.com.