Messages in NODE-RED - message

I am trying to send a string value and a number value (both together) in NODE RED to my python funtcion to execute the code directly.
The idea is to be able to change those values fro, the dashboard and when I click the "start button" to send those values to start my python code.
Someone could help me?

The basic idea is to set your number value and string value in an array, and then you can access them by using dot notation or bracket notation.
You can use something like this
msg.payload = [number,string]
Because you will be using an array, you can use msg.payload[0] to access the first element(number) and msg.payload[1] to access the second element.

Related

Question about using API to retrieve cell data

I’m wondering if someone could help me figure out a little issue I’m having. I’m trying to create an iOS shortcut to retrieve specific cell data from a Google Sheets document, and I’m really close, however, I’m hitting this snafu.
For my example, the data entered into the specific cell is: “0+ 5” (without the quotes).
I’m using the following URL to grab the data (with my string ID and API keys X’d out):
https://sheets.googleapis.com/v4/spreadsheets/XXXXXXXXXX/values/Sheet1!D#?key=XXXXXXXXXXXXXXXXX
(Also, the # character after “Sheet1!D” is purposeful….I have shortcuts configured to replace that character with a number I input when running the shortcut)
Anyway, the result I’m getting is:
{"range":"Sheet1!D99","majorDimension":"ROWS","values":[["0+ 5"]]}
Notice the “0+ 5” near the end, which is the data entered in the specific cell.
I know I can mess around with Regex to to have the shortcut specifically match that part of the text, but I’m assuming there’s a way to format the API URL so that it only gives me the data entered — in this case, only
0+ 5
and not all of the other info….am I correct in that assumption? If so, I’d rather go that route and have the shortcut be a bit less convoluted.
Thanks!
Server's response is in JSON format, meaning, you can use action Get Dictionary From Input and next use action Get Dictionary Value. Type in values for the key.
Check this image:
Hope this helps.

Making custom slots using Regex in amazon Lex

I want to make custom slots that accepts any and all entries as long as those entries follow a certain regex pattern, eg:any number of alphabets or numbers but without a space in between. Can anyone tell me if there is a way in amazon lex to achieve it?
Also, if I want to take a certain type of data, say, email ids, but want to give the user option to give any number of email ids (more than one), what is the way to do that.
I am new to Amazon Lex and any suggestions would be appreciated.
Make a slot in Lex console in your intent but do not tick as required, and give any type as slot type.
Now in lambda code, first set the slot to null and then parse the inputText using regex and assign the correct value to the slot.
This way both of your problems will be addressed.
Hope it helps. Let us know if you run in any problems.

Renaming fragments on SPSS

I am not used to SPSS so this question will sound stupid:
I need to change fragments of a cell in spss, exemple:
'1.28'
'2.69'
'3.57'
to
'a.28'
'b.69'
'c.57'
What's the best way to do it?
Tks.
This is assuming the variable you want to recode is called 'VarA', and that it is numeric.
This creates a copy of the variable, converts it to a string, and then uses those values to create a new version that is recoded.
RECODE VarA (ELSE = COPY) INTO VarA_String.
ALTER TYPE VarA_String(A8).
EXECUTE.
COMPUTE VarA_r=REPLACE(VarA_String,'1.','a.').
COMPUTE VarA_r=REPLACE(VarA_String,'2.','b.').
COMPUTE VarA_r=REPLACE(VarA_String,'3.','c.').
EXECUTE.
The syntax is a little different in SPSS Modeler and bear with me as I can only attach one image until I have a certain reputation on SO.
After you convert VarA into a string (which I called to_str) you can use the replace command to change part of the substring, ie:
to_string(VarA)
for the first Derive node, and:
replace('1.','a.',to_str)
for the second Derive node, this command replaces all occurrences of SUBSTRING1 with SUBSTRING2 in STRING and you will get the same result but in Modeler, see the sample stream here
Assuming that these are strings, see the replace function in COMPUTE. If there are just a few, though, just edit the cells in the Data Editor.

biopython qblast function no data returned

I'm trying to blast an 8-mer (string of length 8) against the NCBI database. However, whenever I use qblast, it comes up empty with respect to matches. This is my code:
from Bio.Blast.NCBIWWW import qblast
import Bio.Blast.NCBIXML as parser
a = qblast('blastp','nr','GGMPSGCS')
b = parser.read(a)
print b.alignments`
Whenever I do this, it just prints the empty list []. Why is this happening? Can anyone shine a light on it?
I can get a match using the NCBI online BLAST tool, and I can even get a match if I use a longer kmer like "SSRVQDGMGLYTARRVR". It just happens that all the 8-mers I search come up empty.
From the FAQ at http://biopython.org/DIST/docs/tutorial/Tutorial.html
Why doesn’t Bio.Blast.NCBIWWW.qblast() give the same results as the NCBI BLAST website?
You need to specify the same options – the NCBI often adjust the default settings on the >website, and they do not match the QBLAST defaults anymore. Check things like the gap >penalties and expectation threshold.
Check that qblast is using the same defaults, if not sure, make them explicit. I wouldn't be surprised if it's doing some sort of "read to short" filtering step.
As in this answer, you have to fine-tuning the qblast to override the defaults. The WWW frontend of NCBI-BLAST automatically adjusts your parameters to match the short (8 bp) sequences, but if you do it through Biopython API you have to do it manually.

How do I increment a string value in Google Spreadsheet?

Long time Lurker reporting in! My issue is I'm not sure how to increment an Item no. It follows this format : LK0001 the row below it will be LK0002, below that LK0003 and so on I'm not sure how to automate this process, as you can tell I'm fairly new to google spreadsheets Sorry if it's already answered , I just can't seem to find it! Thanks!
Weej
First of all, I would suggest using the following ID build-up:
LK1000
This way characters (LK) can be separated from integers (1000). Otherwise you would face the problem, that if you increase LK0009 by 1 it becomes LK00010 and not LK0010
ID's need to be "hard coded", meaning =CONCAT or =A1+1 or =MAX(A:A)+1 are not allowed.
Either go by typing LK+max. number and use the ID as a text or go for the integers and use CONCAT when needed.
If you chose to go with the integers, you can easily increment them by doing this:
and then dragging it downwards, yielding:
I've prepared an example for you: How do I increment a string value in Google Spreadsheet?

Resources