All Know q: lines whose (it as string contains “something”) of file “c:\Windows\tru.ini”
but i want to look lines of file “read1.txt” in lines of file “read2.txt”
then out example :
false
true
false
true…
someone can to help me?
All Know q: lines whose (it as string contains “something”) of file “c:\Windows\tru.ini”
but i want to look lines of file “read1.txt” in lines of file “read2.txt”
then out example :
false
true
false
true…
someone can to help me?
Are you comparing line 1 of read1.txt to line 1 of read2.txt, or are you asking does line 1 of read1.txt exist anywhere within read2.txt ? These are very different things.
I Want : línes whose (it as string contains lines of file “file1.txt”)of file "file2.txt"
But it’s error for singular whose.
Where file1 , number line = 5 .
So you want to build a script or a relevance?
I want To make a property of analisys
I don’t think this will work to get you what you want, but this is something that might get you closer:
(lines of file "file1.txt", lines of file "file2.txt") whose (item 0 of it = item 1 of it)
(lines of file "file1.txt", lines of file "file2.txt") whose (item 0 of it != item 1 of it)
Actually, this might be better:
(set of lines of file "file1.txt", set of lines of file "file2.txt")
Then you should be able to take the intersection of the sets to see what is the same between them.
(set 1) - (set 2) should result what is only in set 1 but not in set 2, and do (set 2) - (set 1) which should be what is only in set 2 and not in set 1.
(item 0 of it - item 1 of it, item 1 of it - item 0 of it, intersections of (item 1 of it;item 0 of it) of it) of (set of lines of file "file1.txt", set of lines of file "file2.txt")
Here’s something I’m trying to do. I want to read the unique value of a line of a file and compare it to see if the value exists in another file. I am able parse File 1 but when I try to use it as the variable of what to look for in the lines File 2, I get an error.
exists lines whose (it contains (unique values of (preceding texts of substrings ":" of (substrings after ":x:" of lines whose (it starts with ":") of file "Things2.txt" of folder "C:\Users\User1\Desktop")) as string) of it) of file "Things.txt" of folder "C:\Users\User1\Desktop"
What do you think?
For reference, here are what my two text files contain:
File 1:
:x:this: 1
:x:is: 1
:x:only: 1
:x:a: 1
:x:test: 1
:x:please: 1
:x:do: 1
:x:not: 1
:x:panic: 1
:x:thanks: 1
File 2:
:x:celebrate:1
:x:good:1
:x:times:1
:x:come:1
:x:on:1
What is it you are trying to assert? That Things2.txt contains a matching line in Things1.txt? or that Things1.txt contains a matching line in Things2.txt? or that all lines match? or that a specific line matches? or that any line matches between the two?
Try this:
exists lines whose ( (unique values of (preceding texts of substrings ":" of (substrings after ":x:" of lines whose (it starts with ":") of file "Things2.txt" of folder "C:\Users\User1\Desktop")) as string) contains it) of file "Things.txt" of folder "C:\Users\User1\Desktop"
Thanks of all for your help.
This would pull unique text from any line (because it can occur more than once in “Things2.txt”) “Things2.txt” after the first “” and before the next “:” and see if that text exists anywhere within “Things.txt” (because the unique value can occur only once in “Things.txt”). Unfortunately your relevance gives me the same error I was getting from my first run through which is “the left operand of ‘contains’ must be singular”.
Given the examples above, this evaluation should come back to “False”. I changed it around a bit and now it has a inspector error:
exists lines whose ( (unique values of (preceding texts of substrings ":" of (substrings after ":x:" of lines whose (it starts with ":") of file "Things2.txt" of folder "C:\Users\User1\Desktop")) as string) of it) of file "Things.txt" of folder "C:\Users\User1\Desktop"
I need to investigate the way to do this. I think it needs to be a string set for it to work, but I’m pretty sure there is a way.
I’m still not completely certain what the goal is. You want to know all items within Things2.txt that also occur in Things.txt ?
Yes. I want to compare two files and make sure all unique values of “Things2.txt” exists within a line somewhere within “Things.txt”.
This should be it:
not exists unique values whose( (content of file "Things.txt" of folder "C:\Users\User1\Desktop") does not contain it ) of preceding texts of lasts ":" of following texts of firsts ":x:" of lines whose (it starts with ":") of file "Things2.txt" of folder "C:\Users\User1\Desktop"
All unique values of Things2.txt :
unique values of preceding texts of lasts ":" of following texts of firsts ":x:" of lines whose (it starts with ":") of file "Things2.txt" of folder "C:\Users\User1\Desktop"
All unique values of Things2.txt that do not occur within Things1.txt:
unique values whose( (content of file "Things.txt" of folder "C:\Users\User1\Desktop") does not contain it ) of preceding texts of lasts ":" of following texts of firsts ":x:" of lines whose (it starts with ":") of file "Things2.txt" of folder "C:\Users\User1\Desktop"
All the unique values of Things2.txt that DO occur within Things1.txt:
unique values whose( (content of file "Things.txt" of folder "C:\Users\User1\Desktop") does contain it ) of preceding texts of lasts ":" of following texts of firsts ":x:" of lines whose (it starts with ":") of file "Things2.txt" of folder "C:\Users\User1\Desktop"
Also, if both files will always have the values surrounded by:
:x: followed by :
Then that can be used to better parse the file contents for a match:
not exists unique values whose( (content of file "Things.txt" of folder "C:\Users\User1\Desktop") does not contain ( ":x:" & it & ":") ) of preceding texts of lasts ":" of following texts of firsts ":x:" of lines whose (it starts with ":") of file "Things2.txt" of folder "C:\Users\User1\Desktop"
As always @jgstew your relevance-fu is highly appreciated. I guess I should have been clearer on the contents of Things.txt.
Here is the low-down on what exactly I’m trying to accomplish. I want to take the “/etc/passwd” file and compare it to the “/etc/group” file and ensure all group ids that are listed in"passwd" are listed in “groups”.I noticed some issues in the way it reads where if I have a group id of 70 AND a group id of 700 it breaks the current way of the check since 700 also contains 70 so I guess what I need to do is more something like this:
exists (unique values of preceding texts of firsts ":" of following texts of firsts ":" of following texts of firsts ":x:" of lines of file "passwd" of folder "C:\Users\xeebk62\Desktop") of unique values of following texts of firsts ":x:" of lines of file "groups" of folder "C:\Users\xeebk62\Desktop"
It looks like, after individually selecting the two clauses for each file, this gives me the lists of values I want to get but it’s not doing an apples to apples comparison of the two and seeing that there are some missing from the “groups” file after testing with a value that isn’t in “passwd”. Obviously it would be fine if “groups” had things that weren’t in “passwd” but I want it to be true if it’s the other way around.
unique values whose( (content of file "Things.txt" of folder "C:\Users\User1\Desktop") does not contain (":x:" & it & ":") ) of preceding texts of lasts ":" of following texts of firsts ":x:" of lines whose (it starts with ":x:") of file "Things2.txt" of folder "C:\Users\User1\Desktop"
“” and “:” are the tokens surrounding the data you are interested in. You need to parse the data out that is between these tokens to get all the data from the first file. Then you need to add on the tokens surrounding the data in the second file, which in this case are the same tokens. This will essentially validate the beginning and endings of the data so that 70 does not match on 700.
This is what I added:
(":x:" & it & ":")
Just because I hate to use "preceding text of following text of following text of " any time I can avoid it…consider something like
tuple string items 3 of concatenation ", " of substrings separated by “:” of lines of file
The space after the comma in the concatenation is important, tuple strings are delimited by the comma-space pair.
Parsing that way can be tricky if the string already contains strings, but that shouldn’t occur until the gecos or member fields, where we don’t care.
I think it is better to use preceding text and following text in this case since the strings on either side are different and it is more precise. There are other cases where I would agree that using tuple string item instead.
Just because I’ve been on a kick playing with Regular Expressions these days, you might try a form of this:
elements of (set of parenthesized parts 2 of matches(regex("(^[^:][:][^:][:][^:][:])([^:])")) of lines of file “/etc/passwd” - set of parenthesized parts 2 of matches(regex("(^[^:][:][^:][:])([^:]*)")) of lines of file “/etc/group”)
Given a passwd.txt of
user1:x:1:45:/home/user1:/bin/sh:this is user1
user2:x:2:67:/home/user2:/bin/sh:this is user2
user3:x:3:89:/home/user3:/bin/sh:this is user3
And group.txt of
group1:x:45:user1,user2
group2:x:67:user2,user3
This gives the results:
q: elements of (set of parenthesized parts 2 of matches(regex("(^[^:][:][^:][:][^:][:])([^:])")) of lines of file “c:\temp\passwd.txt” - set of parenthesized parts 2 of matches(regex("(^[^:][:][^:][:])([^:]*)")) of lines of file “c:\temp\group.txt”)
A: 89
T: 2.022 ms
I: plural string
I like having a third way to do it.
RegEx is definitely the way to go for complicated text parsing, but it is also harder to understand how it behaves just by reading the regex() definition since it is so powerful yet complex.
I feel that if it can be done by just parsing based upon beginning and ending tokens using “preceding” and “following” then that is the way to go. I feel that is more readable, adaptable, and reusable than most RegEx.
The main advantage to RegEx is that you can often handle many different cases with a single RegEx where it would require a multitude of “If Then Else” in combination with “preceding” and “following” to do the same work. In these cases RegEx may be preferred, but there is not always a clear answer.
Also, we have ran into some issues with RegEx on the Mac. I don’t remember the details, but we had to fall back to using “preceding” and “following”.