I'm using jython scripting with a datasource. Datasource columns are MR1, MR2, MR3.
Here is my script.
x=float(context.getValue("datasource", "MR1"))
y=float(context.getValue("datasource", "MR2"))
z=float(context.getValue("datasource", "MR3"))
input1 = ((1+x/float(100))*(1+y/float(100))*(1+y/float(100)))-1
return SOAPUtil.getXMLFromString([str(input1)])
I'm using x, y and z as variables.. there are many columns maybe more than 50 for each column I cant declare a variable like x, y and z for each column... So, what I'm trying to do is get the column count and iterate the column and row through FOR loop.
I checked the help contents and there is no columncount method for this tool.
Can you please help me with this script.
Thank you.
In java with selenium automation also, we do NOT have column count. navigation takes place with rowcount and rowdata ONLY. But we have getLastColumnNum. However with jython i'm not very sure as i have just started working with it...please try something equivalent-maybe like lastcolumn....
Related
I have:
A Sheet with Columns for A, B, and C.
A Doc with a templatized text that includes A, B, and C values.
A output Doc where I want to have the templatized text multiple times, adjusting for A, B and C.
Is there a way to get a script that does this?
Reading your steps I can see that you are very close to finishing your project. You only need to use the following methods.
First you would need to open and read your spreadsheet. You can gather all the data with a combination of Spreadsheet.getDataRange() and Range.getValues(). You will end up with an array with the A, B and C columns.
Furthermore you would need to open the Doc template. This step is very similar to the previous one, you can achieve it by using Document.getBody() and Body.getText().
Now you have the data and the template, you only need to join them together. To manage it, run the data rows in a loop substituting the placeholders in the template with the data rows. This way you will end up with an output array as big as your spreadsheet data. At this point you can write it down on the output Doc by using Document.getCursor() and Position.insertText() with each output line.
Please, feel free to ask me any doubts to better help you.
Ive been searching the internet to what I thought would be a straight forward question to answer. Hope you guys can help?
I am using for each loop to look for specific files and move them with file system task to a different folder.
Say I have 10 csv files. called listed A to J
I only want to move a,e and j but cant seem to get the foreachloop to look for that group.
In the enumerator Files text box i have tried inserting the 3 file names split by various separators, but SSIS thinks its all one specific file and none of the 3 get moved.
Can someone advise how it can be done? Just to confirm, I dont to use wild card logic just group of specific file names - similur to the IN function of SQL query
Thanks in advance
now added img - please advise how to slect 3 specific files in the text box with arrow
Since OP isn't able to proceed with just my comment, I'll explain a bit more in detail -
Use an EXECUTE SQL TASK to dump the names of the files needed into an SSIS object (to do this you could use a stored procedure or an SQL query). Create an object-type variable in the variables tab prior, change the output in the EXECUTE SQL TASK to Full Result Set and map the result to the object you just created. Now this object holds the list of files you need to loop through.
Now drag-and-drop a ForEach container from the SSIS toolbox. It should be configured as a ForEach ADO Enumerator and map the object to it. Create another variable of type string that will hold the file names after each iteration of the ForEach container. Map this also in the Variables tab of the ForEach container.
Now, place the File System Task which you would use to move these files into the ForEach loop. Use the file-name-variable you created to move just the required files.
Now if you're not sure what SQL query to use for your case in step 1 to get the 3 file names -
SELECT 'A.csv'
UNION
SELECT 'E.csv'
UNION
SELECT 'J.csv'
I am trying to find a specific value inside an array. The array is composed from data in MySQL database and looks like:
info = [#<Info1: bla, Info2: blo>,#<Info1: bli, Info2, Ble>]
Now I want to get every Info1's value from it, but I do not know how.
The array was formed by calling
info = Info.find(:all)
Can anyone help me?
I am using Rails 2.2.2 (don't ask, can't do anything about it) and Ruby 1.8.
Edit: More details
Info is a database, where Info1 and info 2 are the columns. Calling it with info = Info.find(:all) returns the array above.
What I have tried so far involves trying to go through the array with each, but so far no luck.
Most of what I have tried like
a.grep(/^info1/)
and
info.select(|i| i.name == "info1")
all return empty arrays
Edit
Nevermind, I found the answer. I was thinking too weird. The answer is
info.each do |object|
puts object.info2
end
What's your selection criteria? You can do something like
info.select{|i| i.name == 'hello' }
and you will get all the Info objects with name = 'hello'.
But I would prefer to change the query, if you can, to filter them in the database query directly.
The Goal
I am trying to create a spreadsheet using some custom functions. The purpose for the sheet is to keep score in a quizzing competition. The top row has the question number, the second row the score, and the third number the number of fouls for that question.
The Problem
After noticing some problems with the score calculation, I was able to narrow the problem down to the part of the code where I add up the fouls that occurred prior to the current question. It seems that no matter what I do, the code sums over the question row, not the foul row.
Attempted Solutions
The extremely strange thing is that no matter what I change the reference cells to, it always produces the same result (i.e. it still references the question row same as it always has).
Example
I'm not sure if that makes any sense, but I've made an example sheet here so you can see what I'm talking about and try to figure out what is going on. Keep in mind that I'm well aware that I could accomplish what I'm trying to do in the example sheet with a simple built-in formula, but since there's no way to use worksheet formulas on the Apps Script side, I have to create my own version of it. I've made the example editable for anyone with the link, so you should have full access to it; but if you have problems, just let me know, and I'll see what I can do to fix it.
In your For loop, you are summing the indexes rather than the values:
Try:
for (var PrevValue in PrevValues[0]) {
Sum = Sum + Number(PrevValues[0][PrevValue]);
}
EDIT:
You'll also need to account for the case where you pass in a single cell rather than a range (=mySum($B4:B4)), because in that case the value is passed directly instead of an array.
if(PrevValues instanceof Array){
for (var PrevValue in PrevValues[0]) {
Sum = Sum + Number(PrevValues[0][PrevValue]);
}
}else
Sum = PrevValues;
I'm trying to create an SSIS package that reads a mapping table that contains foreign key information and tables they point to and store the full result set to be used to populate 7 columns representing columns in the result set that is then used to update an xxxSID column on 6 servers.
I'm stuck! Please help.
I've created the SQL Task with query to build the result set and mapped to object variable SidMap and the task runs successfully however, I don't know where to go from there. Some blogs say create a ForEachLoop Container and map the object variable to the collection which I've done. I've also created string variables representing the 7 columns but don't know how to populate them.
The blogs I've read so far suggest this can only be done from a Script task. Is that true? If so how is it done?
Another user posted a question that sounded like he may be doing the same or very similar thing using a SQL Task but I didn't see how he was populating the column object variables and then converting data into string variables.
SSIS Result set, Foreachloop and Variable
Currently I'm updating tables manually using a cursor. If anyone cares to see the code I can post it but didn't think it relevant to the question other than providing a clear picture of what I'm doing.
I would create a For Each Loop Container using the Foreach ADO Enumerator, and map the object variable to the collection. I would map the 7 string variables on the Variable Mappings page.
This process is documented in detail here:
http://technet.microsoft.com/en-us/library/cc879316.aspx
A common "gotcha" is mismatched datatypes between the result set and the Variables. To avoid this I always wrap CAST ( ... AS NVARCHAR ( 4000 ) ) or similar around the columns in the dataflow that produces the dataset, and all my receiving Variables are String datatype.