Storetext from a table choice correct lines to store for Selenium Ide Ui Vision Kantu - extract

I need to storetext all lines from a table where CODICE CATASTALE have a value
I add an image to show, I need to save all line in variable with storetext with this characteristic CODICE CATASTALE have a value, in the image I add 1 - 2 - 3 - 4 to explain line to store.
This is a relative storetext when CODICE CATASTALE have a value stored the line.
Here the page
nonsolocap.it/cap?k=56040
Image

After the execution such script in Selenium IDE table variable will contain data from the table. xpath_to_all_rows_with_CODICE_CATASTALE should be replaced with corresponding xpath.
store xpath count | xpath = xpath_to_all_rows_with_CODICE_CATASTALE | n
store | 0 | j
while | ${j} < ${n} |
store | | rowElement
store | 0 | i
while | ${i} < 7 |
store text | xpath = xpath_to_all_rows_with_CODICE_CATASTALE[${j}]/td[${i}] | element
execute script | if (${i} != 0) var arr = ${rowElement}; else var arr = []; var element = ${element}; arr.push(element); return arr; | rowElement
execute script | return Number(${i}) + 1; | i
end| |
execute script | if (${j} != 0) var arr = ${table}; else var arr = []; var rowElement = ${rowElement}; arr.push(rowElement); return arr; | table
execute script | return Number(${j}) + 1; | j
end| |

use scvSave command and give a name for the target for divide raws

Related

Checking discord messages with sql

So I've been trying to check each message from a sql table. My sql table structure is down below:
Example:
| id | | triggervalue | | triggermessage |
| 633666515413237791 | | hello, world, test | | Trigger works! |
(array like string is something like: hello, world, test)
I want to check each message from each triggervalue column to see if message contains a string from array like string.
Here is what I've done:
I tried to merge every single array like string then send(triggermessage) where the same row of the found array contains, then checking for word.
connection.query(`SELECT * FROM triggervalue`, (err, rows) => {
let array = []
for(i = 0; i < rows.length; i++) {
let received = rows[i].jsonstring;
var intarray = received.replace(/^\[|\]$/g, "").split(", ");
array.concat(intarray)
// continue code here...
}
})
However, I can't get the triggermessage of the same row of found array. How would I go for it? I've been stuck here for quite a while... Sorry if this way of asking is wrong, thanks!
(Sorry if my english is bad)

Output Error for Matrix in Python?

I am trying to create a function that outputs a matrix that contains each item in a list on a separate line with lines in between. The only output I'm getting is quotations (''). I do not understand why. I think I set it all up correctly to output what is needed but there has to be something missing?
I included examples below my code.
def show_table(table):
table=[]
s=[[str(e) for e in row] for row in table]
lens= [max(map(len, col)) for col in zip(*s)]
fmt= '\t'.join('{{:{}}}'.format(x) for x in lens)
table= [fmt.format(*row) for row in s]
return '\n'.join(table)
show_table([['A','BB'],['C','DD']])
output:
'| A | BB |\n| C | DD |\n'
print(show_table([['A','BB'],['C','DD']]))
output:
| A | BB |
| C | DD |
The issue is on the second line where you are initialising your list to an empty list. Instead try:
if table is None:
table = []
Perhaps a better way to accomplish this could be:
def show_table(table):
if table is None:
table = []
data = ""
for row in table:
for val in row:
data += "| " + val + " "
data += "|\n"
return data.strip("\n")
print show_table([['a','bb'],['c','dd']])
Output:
| a | bb |
| c | dd |

GAS Split one cell and fill down another

I have the following situation:
Column G Column H
|Black, Brown, Grey| | dog |
|Calico | | cat |
|Green, Blue | | bird|
| ... | | ... |
I would like to split and fill down to this:
Column G Column H
|Black | |dog |
|Brown | |dog |
|Grey | |dog |
|Calico| |cat |
|Green | |bird|
|Blue | |bird|
|... | | ...|
Looking at the script to split a comma delineated cell (Function to split text in cell and create column) I can follow the split but it's the filling down portion that I am having trouble with. I understand I should set up a while loop with the first cell as var = i and the second cell as var = j. Dump the split contents of i to an array and then fill down the array.length. However, I can't seem to get the syntax correct.
I'm pretty new to JS and GAS so any help would be appreciated.
Thanks for the help.
-JH
Here's a custom function that should work for you:
/**
* Splits the array by commas in the column with given index, by given delimiter
* #param {A2:B20} range Range reference
* #param {2} colToSplit Column index
* #param {","} delimiter Character by which to split
* #customfunction
*/
function advancedSplit(range, colToSplit, delimiter) {
var resArr = [], row;
range.forEach(function (r) {
r[colToSplit-1].replace(/(?:\r\n|\r|\n)(\d|\w)/g,", ").split(delimiter)
.forEach(function (s) {
row = [];
r.forEach(function (c, k) {
row.push( (k === colToSplit-1) ? s.trim() : c);
})
resArr.push(row);
})
})
return resArr.filter(function (r) {
return r.toString()
.replace(/,/g, "")
})
}
This function can be used like this:

Copy previous values kettle pentaho

I have an issue and i'm looping on it! :| I hope someone can help me..
So i have an input file (.xls), that is simple but there are a row (lets say its "ROW1") that is like this:
ROW1 | ROW2 | ROW3 | ROW_N
765 | 1 | AAAA-MM-DD | ...
null | 1 | AAAA-MM-DD | ...
null | 1 | AAAA-MM-DD | ...
944 | 2 | AAAA-MM-DD | ...
null | 2 | AAAA-MM-DD | ...
088 | 7 | AAAA-MM-DD | ...
555 | 2 | AAAA-MM-DD | ...
null | 2 | AAAA-MM-DD | ...
There are no stardard here, like you can see.. There are some lines null (ROW1) and in ROW2, there are equal numbers, with different association to ROW1 (like in line 5 and 6, then in line 8 and 9).
My objective is to copy and paste the values from ROW1, in the ROW1 after when is null, till isn't null. Basically is to copy form previous step, when is null...
I'm trying to use the "Formula" step, by using something like:
=IF(AND(ISBLANK([ROW1]);NOT(ISBLANK([ROW2]));ROW_n=ROW1;IF(AND(NOT(ISBLANK([ROW1]));NOT(ISBLANK([ROW2]));ROW_n=ROW1;ROW_n=""));
But nothing yet..
I've tried "Analytic Query" but nothing too..
I'm using just stream a xls file input..
Tks very much, any help is very much appreciiated!!
Best Regardsd!
Well i discover a solution, adding a "User Defined Java Class" with the code below:
import java.util.HashMap;
private FieldHelper output_field, card_field;
private RowSet out, log;
private String previou_card =null;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
if (first)
{
first = false;
out = findTargetRowSet("out");
output_field = get(Fields.Out, "previous_card");
} else {
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
r = createOutputRow(r, data.outputRowMeta.size());
if (previous_card != null) {
output_field.setValue(r, previous_card);
}
if (card_field == null) {
card_field = get(Fields.In, "Grupo de Cartões");
}
String card = card_field.getString(r);
if (card != null && !card.isEmpty()) {
previous_card = card;
}
// Send the row on to the next step.
putRowTo(data.outputRowMeta, r, out);
}
return true;
After this i have to put a few steps but this help very much.
Thank you mates!!
Finally i got result. Please follow below steps
Below image is full transformation screen.
Data Grid Data will be like these. Sorry for that in my local i don't have Microsoft because of that i took Data Grid. Instead of Data Grid you can drag and drop Microsoft Excel Input step.
Drag and Drop one java script step and write below code.
Last step of transformation, drag and drop Select values step and select the columns.( These step is no necessary)
Final result will be like these.
Hope this helps.

Inserting an array as a table into a Google doc

I am creating a document from a Template, and cannot figure out how to insert a table at the right position.
I have the table in memory as a 2D array, and in the template I have place-holders like this (including the square-brackets):
...
[TABLE 1]
...
[TABLE 2]
...
[TABLE 3]
...
Each of these placeholders is in a 1x1 table.
I have managed to insert my first array in the right position, but when I then search for the following placeholders my array always gets inserted after Table 1.
My code is the following (I found this online and adapted it slightly):
function insertTable(targetdoc, stringToReplace, tableValues) {
var body = targetdoc.getBody();
var searchElement = targetdoc.getActiveSection();
var searchType = DocumentApp.ElementType.TABLE;
var searchHeading = DocumentApp.ElementType.TABLE_CELL;
var searchResult = null;
// Search until the table is found.
while (searchResult = searchElement.findElement(searchType, searchResult)) {
var par = searchResult.getElement().asTable();
var tabletext = par.getText();
var substr=tabletext.search(stringToReplace);
if (substr >0 ) {
var childindex = body.getChildIndex(par);
var oTable = body.insertTable(childindex+1, tableValues);
return oTable;
}
}
}
and the calling code is:
var oTable = insertTable(oOutputFile,"["+cFieldID+"]",aTable);
where oOutputfile is the new doc, cFieldID is the placeholder text, and aTable is the 2D array.
Can anyone help me get this to work, so that it inserts each array into the correct position?
Thanks
I have written something very similar that might prove useful to you, see GAS Template Engine
It will accept any JSON string and replace place holders in a document that match the structure of the JSON. When an array is encountered, the script looks for a place holder in a table and it will create table rows for each element of the array.
So if your JSON string contains an array as below :
var json = { myarr : [ { col1: "a", col2 : "b" }, { col1 : "c", col2 : "d" }] }
then the script will look for a table in the template document that looks like this :
------------------------------------------------------
| $myarr.col1 | $myarr.col2 |
-------------------------------------------------------
and transform that into :
-----------------------------------
| a | b |
-----------------------------------
| c | d |
-----------------------------------
it will keep the formatting of the rows as well.
It is just a proof of concept for a templating engine but it should be enough to solve your problem.
Thanks koma for your solution which I will certainly use in future, however it was a bit of overkill for what I was looking for.
Finally, I found the solution to what I needed after a mammoth debugging session, and my function shown above has now become:
function insertTable(targetdoc, stringToReplace, tableValues) {
var oDoc = targetdoc.getBody(); // Document
var oSR = oDoc.findText(stringToReplace); // SearchResult
var oPara = oSR.getElement().asText().getParent(); // Paragraph
var nIndex = oDoc.getChildIndex(oPara); // Index
var oTable = oDoc.insertTable(nIndex, tableValues); // Table
return oTable;
}
so, for example, if I have a doc (oDoc) with the following placeholder
[TABLE 1]
an array
aData: {{"","column 1","column 2"},{"row 1","data 11","data 12"},{"row 2","data 21","data 22"}}
and a variable
cFieldID = "TABLE 1";
and call my function
oTable = insertTable(oDoc, cFieldID, aData);
oOutputFile.replaceText("\\["+cFieldID+"\\]","");
I obtain the following in lieu of the placeholder text
-----------------------------------
| | column 1 | column 2 |
-----------------------------------
| row 1 | data 11 | data 12 |
-----------------------------------
| row 2 | data 21 | data 22 |
-----------------------------------
This is less generic and powerful than koma's solution, but sufficient for what I need for now.
Chris