I’ve developed this further and have it working however it now fails if there are duplicates in the csv file.
Additionally, I’m trying to extract the relevant line for the particular host name into a property, so I can just look up the property to set each setting (and not do multiple lookups of the file).
so, my relevance looks like the following when it’s working, but fails if there are duplicates:
//sets parameter for location of csv file
parameter “ragcsv” = “{pathname of parent folder of parent folder of client folder of site “actionsite” & “/__BESData/actionsite/__Download/RAG.csv”}”
//checking if the computer exists int he file
if {exists file (parameter “ragcsv” as string) whose (exists (lines of it) whose (it contains ((if computer name contains “.” then (preceding text of first “.” of computer name) else computer name)as uppercase)))}
//some computer names are fully qualified in IEM, but in the csv file, they are hostname only - so this accounts for that
parameter “computer_name” = “{((if computer name contains “.” then (preceding text of first “.” of computer name) else computer name)as uppercase)}”
//set parameter for one of the values in the file
parameter “_Company” = “{preceding text of first “,” of (following text of first “,” of (lines whose (preceding text of first “,” of it = (parameter “computer_name”)) of file (parameter “ragcsv” as string)))}”
setting “_Company”="{parameter “_Company” of action}" on “{parameter “action issue date” of action}” for client
now…this works fine, however I have multiple parameters i’m taking out of the file so multiple lookups of the csv file. I want to set a property to make it more efficient
property “inventory_string” = (lines whose (preceding text of first “,” of it = computer name) of file (parameter “RAG.csv”))
this should set the parameter as, for example: “HOSTNAME,UK,WALES,IBM”
Q: (lines whose (preceding text of first “,” of it = computer name) of file “C:__Temp\RAG.csv”)
A: HOSTNAME,UK,WALES,IBM
T: 1.468 ms
which I should be able to use to get my values for my settings,
however, I cannot use the property if it returns multiple lines form the file if there are duplicates!..
Q: (lines whose (preceding text of first “,” of it = computer name) of file “C:__Temp\RAG.csv”)
A: HOSTNAME,UK,WALES,IBM
A: HOSTNAME,UK,WALES,IBM
A: HOSTNAME,UK,WALES,IBM
A: HOSTNAME,UK,WALES,IBM
T: 2.812 ms
how to do I take just the first result of that…I’ve tried the following but it doesn’t work if there are no duplicates…
//when duplicates exist…
Q: preceding text of first “|” of (concatenations “|” of lines whose (preceding text of first “,” of it = computer name) of file “C:__Temp\RAG.csv”)
A: ADMINIB-TJ8REI0,UK,WALES,IBM
T: 1.142 ms
//when no duplicates exists…
Q: preceding text of first “|” of (concatenations “|” of lines whose (preceding text of first “,” of it = computer name) of file “C:__Temp\RAG.csv”)
E: Singular expression refers to nonexistent object.