I Googled it but i'm not able to find a GOOD solution.
My goal is to put a string which is composed of 6 lines in one string, and only one, in a variable.
For example, my string can look like :
a
b
c
and I want it to be in one string. I tried the thing witch ^, or with ECHO " " but it doesn't work : the cmd put an error "not recognized as an internal command" (and it's normal, it's just some sentences, not batch commands!)
Thanks, Clément
Not so simple but possible :
#echo off
REM Creating a Newline variable (the two blank lines are required!)
set NLM=^
set NL=^^^%NLM%%NLM%^%NLM%%NLM%
REM Example Usage:
setlocal enableDelayedExpansion
set "string_with_new_lines=a!nl!b!nl!c"
echo %string_with_new_lines%
Aacini has a simpler solution for this using empty variable,but I'm struggle to find the link.
Following the comments on the post answer of #npocmaka
It's currently in Python, so the """ thing works.
requete = """
PREFIX resources: <http://www.fluidops.com/resource/>
SELECT DISTINCT ?id ?marque ?modele WHERE {
?voiture resources:uid ?id.
?voiture resources:bpqmqvc ?marque. #myComment
?voiture resources:bpqmodvc ?modele
}
"""
Related
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
thanks to a fellow stack-overflower, i have recently learned how to use 'run-result' to pass patch attributes as input variables to a procedure. However, i am struggling using the same approach when i want to modify the patch attribute. To clarify, in the code below, i am successfully passing the attribute 'attr1' to Export.List.to.file, but when I pass it to Import.List.from.file, i get an 'this isn't something you can use set on' error in the line 'ask datum [set (run-result #attr) file-read]]'
can anyone help?
to setup
clear-all
let patch-list sort patches
ask patches [set attr1 random 10]
Export.List.to.file "attr1" patch-list "attr1.txt"
Import.List.from.file "attr2" patch-list "attr1.txt"
end
to Export.List.to.file [#attr #patch-list #filename]
let list1 map [ p -> [run-result #attr] of p ] #patch-list
carefully [file-delete #filename] []
file-open #filename
foreach list1 [?datum -> file-print ?datum]
file-close
end
to Import.List.from.file [#attr #patch-list #filename]
file-open #filename
foreach #patch-list [datum -> ask datum [set (run-result #attr) file-read]]
file-close
end
To be perfectly honest, I can't explain exactly why it doesn't work in the second case and does work in the first case. My best guess is that in the first case, the attribute is treated as a reporter, something to be used by other processes. In the second case, the attribute is treated as a property, for which different rules apply.
The workaround I would use is to turn the entire set command into a single string, and then turning it back into a command by using run. To combine the different parts of the command into a single string, you can use word: let commandstring (word "set " #attr-name " random 5"). Notice how I use quotation marks for "set " and " random 5" but I don't use them for #attr-name, since I don't want #attr-name in the final string, but rather the string contained within #attr-name. In my case that would be "attr3".
to go-3
change-attribute "attr3" patches
end
to change-attribute [#attr-name patchset]
let commandstring (word "set " #attr-name " random 5")
show commandstring
; this gives "set attr3 random 5"
ask patchset [run commandstring ]
end
I am fairly new to Puppet and Ruby. Most likely this question has been asked before but I am not able to find any relevant information.
In my puppet code I will have a string variable retrieved from the fact hostname.
$n="$facts['hostname'].ex-ample.com"
I am expecting to get the values like these
DEV-123456-02B.ex-ample.com,
SCC-123456-02A.ex-ample.com,
DEV-123456-03B.ex-ample.com,
SCC-999999-04A.ex-ample.com
I want to perform the following action. Change the string to lowercase and then replace the
-02, -03 or -04 to -01.
So my output would be like
dev-123456-01b.ex-ample.com,
scc-123456-01a.ex-ample.com,
dev-123456-01b.ex-ample.com,
scc-999999-01a.ex-ample.com
I figured I would need to use .downcase on $n to make everything lowercase. But I am not sure how to replace the digits. I was thinking of .gsub or split but not sure how. I would prefer to make this happen in a oneline code.
If you really want a one-liner, you could run this against each string:
str
.downcase
.split('-')
.map
.with_index { |substr, i| i == 2 ? substr.gsub(/0[0-9]/, '01') : substr }
.join('-')
Without knowing what format your input list is taking, I'm not sure how to advise on how to iterate through it, but maybe you have that covered already. Hope it helps.
Note that Puppet and Ruby are entirely different languages and the other answers are for Ruby and won't work in Puppet.
What you need is:
$h = downcase(regsubst($facts['hostname'], '..(.)$', '01\1'))
$n = "${h}.ex-ample.com"
notice($n)
Note:
The downcase and regsubst functions come from stdlib.
I do a regex search and replace using the regsubst function and replace ..(.)$ - 2 characters followed by another one that I capture at the end of the string and replace that with 01 and the captured string.
All of that is then downcased.
If the -01--04 part is always on the same string index you could use that to replace the content.
original = 'DEV-123456-02B.ex-ample.com'
# 11 -^
string = original.downcase # creates a new downcased string
string[11, 2] = '01' # replace from index 11, 2 characters
string #=> "dev-123456-01b.ex-ample.com"
I have a shell file with the below SQL statements in it:
SELECT distinct vpi.pin_id_e
FROM MSSINT.V_DSLAMS vd,
MSSINT.v_pin_inventory_old vpi
where vd.dslam like '%#%'
and vd.dslam_id = vpi.dslam_id ;
select pa.circuit_design_id,pa.node_address,c.exchange_carrier_circuit_id,c.type,c.rate_code,c.status
from ASAP.port_address pa,
asap.circuit c
where pa.equipment_id = 4561233 and pa.circuit_design_id is not null
and pa.circuit_design_id = c.circuit_design_id;
In the above content of my shell file, I have to extract the table or view names alone (those between from and where keywords).
I have seen a lot of suggestions to get words based on position, but I don't want those since they will not work like between operators.
awk 'toupper($0) ~ /^FROM/ { getline;flag=1 } toupper($0) ~ /^WHERE/ { flag=0 }flag' filename
With awk, convert the string to upper case and then pattern match against FROM at the beginning of the line. If this exists, read in the next line and set flag to one. When WHERE is encountered at the beginning of the line, set the flag equal to 0. The complete line will then only print when flag is set to one i.e. between the from and where lines
I am attempting to use a Local variable in a DirCopy command but when I insert the $Variable into the C:\Users\store$Variable\Desktop path it attempts to read the path literally instead of using the $Variable.
The objective is to create a prompt for the Store number and insert that number into a bunch of DirCopy lines to ensure we get the profiles that contain only that number. The issue is that the profiles are one word, ex. store123, reciever123.
This is what I put together so far but I can't get it to take the variable in this way.
Local $STORE = InputBox ( "Store Number" , "What Store is This?" )
DirCopy ( "\\192.168.1.3\C$\Documents and Settings\store$STORE\Desktop" , "C:\Users\Store$STORE\desktop" )
DirCopy ( "\\192.168.1.3\c$\Documents and Settings\Profile$STORE\Desktop" , "C:\Users\Profile$STORE\Desktop")
Is there a formatting issue? or is this not possible in AutoIT?
Method 1: Concatenation
In order to use Variables inside strings, you need to concatenate them, by using the & operator:
$nVar = 42
$sStr = "Hello, " & $nVar & "World!"
; $sStr will now hold: "Hello, 42World!"
Method 2: Expansion
However, there is a Opt() flag ExpandVarStrings that enables inline variable use:
Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand
$nVar = 42
$sStr = "Hello, $nVar$World!"
; $sStr contains: "Hello, 42World!"