How to use #Contains with #Implode in Lotus Formula - lotus-notes

I have a document item called Pathname which is Text List containing paths to databases. I need to create a view, with only specific documents, which contain a specific database path in Pathname item.
I have tried these statements but none has worked:
1.#isMember("Databasepath",Pathname)
2.#Contains(#Implode(Pathname);"Databasepath")
Thank You for any suggestion.

There is no need for the "implode" in your code.
If Pathname looks like this:
apps\database1.nsf; apps\database2.nsf; mail\mailfile1.nsf;
and you want to filter out all in "apps" path, then the formula would look like this:
#Contains( PathName; "apps\\" )
Don't forget to duplicate the backslashes, if you "hardcode" them, as they are escape characters.
But now think about a Pathname containing:
localapps\db1.nsf; apps\db2.nsf; local\apps\db3.nsf
Then the formula above would select ALL entries. In that case this formula would be better:
#Contains( "#" + PathName; "#apps\\" )
Or (if the given path is always at the beginning):
#Begins( PathName; "apps\\" )

If it's truly a text list (i.e., "Path1\Db1.nsf" : "Path2\Db2.nsf" : "Path3\Db3.nsf"), then you should just be able to use the equals operator because a comparison of a scalar to a list value returns true if the scalar matches any of the list values. This detail of the semantics of formula language actually makes a lot of uses of #Contains unnecessary!
I.e., it should be as simple as
SELECT Pathname = "Path1\\Db1.nsf";
or if Pathname is not already case normalized, then
SELECT #uppercase(Pathname) = "PATH1\\DB1.NSF";

Related

how do I get rid of leading/trailing spaces in SAS search terms?

I have had to look up hundreds (if not thousands) of free-text answers on google, making notes in Excel along the way and inserting SAS-code around the answers as a last step.
The output looks like this:
This output contains an unnecessary number of blank spaces, which seems to confuse SAS's search to the point where the observations can't be properly located.
It works if I manually erase superflous spaces, but that will probably take hours. Is there an automated fix for this, either in SAS or in excel?
I tried using the STRIP-function, to no avail:
else if R_res_ort_txt=strip(" arild ") and R_kom_lan=strip(" skåne ") then R_kommun=strip(" Höganäs " );
If you want to generate a string like:
if R_res_ort_txt="arild" and R_kom_lan="skåne" then R_kommun="Höganäs";
from three variables, let's call them A B C, then just use code like:
string=catx(' ','if R_res_ort_txt=',quote(trim(A))
,'and R_kom_lan=',quote(trim(B))
,'then R_kommun=',quote(trim(C)),';') ;
Or if you are just writing that string to a file just use this PUT statement syntax.
put 'if R_res_ort_txt=' A :$quote. 'and R_kom_lan=' B :$quote.
'then R_kommun=' C :$quote. ';' ;
A saner solution would be to continue using the free-text answers as data and perform your matching criteria for transformations with a left join.
proc import out=answers datafile='my-free-text-answers.xlsx';
data have;
attrib R_res_ort_txt R_kom_lan length=$100;
input R_res_ort_txt ...;
datalines4;
... whatever all those transforms will be performed on...
;;;;
proc sql;
create table want as
select
have.* ,
answers.R_kommun_answer as R_kommun
from
have
left join
answers
on
have.R_res_ort_txt = answers.res_ort_answer
& have.R_kom_lan = abswers.kom_lan_answer
;
I solved this by adding quotes in excel using the flash fill function:
https://www.youtube.com/watch?v=nE65QeDoepc

splitting directory fileparts into sections using matlab / octave

I would like to split pathstr into separate parts how can I do this? See example below.
PS: I'm using octave 3.8.1
dpath='tmp/h1/cli/pls/03sox_a_Fs_1000/'
[pathstr,name,ext] = fileparts(dpath)
>>>pathstr = tmp/h1/cli/pls/03sox_a_Fs_1000
If all I want is 03sox_a_Fs_1000 or pls
How can I do this?
Please note the filenames will change and could be of different lengths.
You can use strsplit (here using Matlab) to split your string (believe it or not!) using the delimiter /:
pathstr = 'tmp/h1/cli/pls/03sox_a_Fs_1000'
[Name,~] = strsplit(pathstr,'/')
Now Name looks like this:
Name =
'tmp' 'h1' 'cli' 'pls' '03sox_a_Fs_1000'
So you can select the last element using the end keyword and curly braces since the output of strsplit is a cell array:
Name = Name{end}
or end-1 to retrieve pls.
This applies to names of any length or format, as long as they are separated by /.

How to find and replace a string in Matlab

So here is my problem:
I have a list of names in Matlab in a cell array.
I automatically create directories and .mat files for each name.
My problem is that some of these names contains '/' and therefore everything go wrong when I create the directory…
So I am trying to find an efficient way to find '/' and replace them.
So far I've tried to find them using the findstr function. It then gives me a cell array with the indexes where '/' appears. So when the name doesn't contain any '/' it returns {[]} and when the function find it, it returns {[i]}.
Now i'd like to have a logical condition that says if findstr is not empty then do something. I've tried with the isempty function but it doesn't work (it's never empty…)
So does anyone have a solution to this?
Thanks
Use regexprep to replace the character:
list = {'aaa', 'bb/cc', '/dd/'};
replace_from = '/'; %// character to be replaced
replace_to = '_'; %// replacing character
list_replaced = regexprep(list, replace_from, replace_to);
gives
list_replaced =
'aaa' 'bb_cc' '_dd_'

How to match strings with "like" keyword?

I'm prompting the user to enter a SaleLotNumber (string) and I'm having trouble with the formula. I have multiple entries with "20" in the SaleLotNumber but when I enter that in, I don't get anything on the report. When I enter the full SaleLotNumber in the parameter, I get the specific value from the database but I would like to enter only two numbers into the parameter and get all entries with those numbers in that order. Here's what I have:
{viewDealers_Drivetime.SaleLot} like {?SaleLotNumber}
What can I do do fix this?
I'm going to assume that {?SaleLotNumber} is a single-value parameter. To match all strings with a "20" in them, you need to use wildcards. For example, you can match a string like "012056" or "98720" by doing:
{viewDealers_Drivetime.SaleLot} like '*' + {?SaleLotNumber} + '*'
where '*' is Crystal's wildcard and {?SaleLotNumber}="20"

Oracle/SQL - Removing undefined chars from string

I currently have an assignemnt where i have to handle data from a lot of countries. My customer have given me a list of acceptable characters, lets call it:
'aber =*'
All other characters should just be changed to '_'.
I know the conversion for my country's specific chars (æøå), easily done with something like
select replace ('Ål', 'Å', 'AA') from dual;
But how would i go about removing all unwanted "noise" without splitting it up in char-by-char comparison?
For example "bear*2 = fear" should become "bear*_ = _ear" as 2 and f are not in the accepted list.
Oracle 10g and up. As one of the approaches, you can use regular expression function regexp_replace():
select regexp_replace('bear*2 = fear', '[^aber =*]', '_') as res
from dual
res
------------------------------
bear*_ = _ear
Find out more about regexp_replace() function.

Resources