Jump to content
UBot Underground

How to romeve a line that contains a specific word


Recommended Posts

The following script creates a table, then puts it in a list so that we can loop through the lines. It removes every line that doesn't contain ,yes,yes. Then it simply creates a new table, this time with the updated list.

clear all data
create table from text(&Christians,"Name,Religion,Do you sometimes read The Bible?,Is Jesus the only way to Heaven?
John,Christian,yes,no
Bob,Christian,no,yes
Stefanie,Christian,yes,yes
Alena,Christian,yes,yes
Suzan,Christian,no,no
Rebecca,Christian,yes,yes
Jessica,Christian,yes,yes
Alex,Christian,yes,yes
Franco,Christian,no,yes
Benedict,Christian,yes,no
Feona,Christian,yes,no
Samantha,Christian,yes,yes")
add list to list(%Christians,$list from text(&Christians,$new line),"Delete","Global")
set list position(%Christians,0)
loop while($comparison($list position(%Christians),"< Less than",$list total(%Christians))) {
    if($not($contains($next list item(%Christians),",yes,yes"))) {
        then {
            remove from list(%Christians,$subtract($list position(%Christians),1))
            set list position(%Christians,$subtract($list position(%Christians),1))
        }
        else {
        }
    }
}
create table from text(&REAL_Christians,"Name,Religion,Do you sometimes read The Bible?,Is Jesus the only way to Heaven?
{%Christians}")

Link to post
Share on other sites
On 8/10/2023 at 2:48 PM, Jaro said:

The following script creates a table, then puts it in a list so that we can loop through the lines. It removes every line that doesn't contain ,yes,yes. Then it simply creates a new table, this time with the updated list.

clear all data
create table from text(&Christians,"Name,Religion,Do you sometimes read The Bible?,Is Jesus the only way to Heaven?
John,Christian,yes,no
Bob,Christian,no,yes
Stefanie,Christian,yes,yes
Alena,Christian,yes,yes
Suzan,Christian,no,no
Rebecca,Christian,yes,yes
Jessica,Christian,yes,yes
Alex,Christian,yes,yes
Franco,Christian,no,yes
Benedict,Christian,yes,no
Feona,Christian,yes,no
Samantha,Christian,yes,yes")
add list to list(%Christians,$list from text(&Christians,$new line),"Delete","Global")
set list position(%Christians,0)
loop while($comparison($list position(%Christians),"< Less than",$list total(%Christians))) {
    if($not($contains($next list item(%Christians),",yes,yes"))) {
        then {
            remove from list(%Christians,$subtract($list position(%Christians),1))
            set list position(%Christians,$subtract($list position(%Christians),1))
        }
        else {
        }
    }
}
create table from text(&REAL_Christians,"Name,Religion,Do you sometimes read The Bible?,Is Jesus the only way to Heaven?
{%Christians}")

Thank you so much Jaro!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...