I want to create a script, where the users inputs in the beginning something, and this variable input should be used for the rest of the loop (without asking for input again).
The best way i could come up with was to create two iMacros, one which asks for the input, and the other one who uses the input and loops it.
The major problem is, i can't save the input in Downloads/Datasource because the same iMacros should be used with other firefox instances. Which means, if the user inputs A on the first instance and on the next B then after the second loop of both all instances are using the varaible B. And i can't make multiple scripts since the user should have the ability to use unlimited times this script.
You can save easy the input in ‘Downloads/Datasource’. However make your second macro read this input only once:
SET !LOOP 1
SET !DATASOURCE inputs.csv
SET input EVAL("('{{!LOOP}}' == 1) ? '{{!COL1}}' : '{{input}}';")
' your further code here '
Related
I have a value I am trying to increment by 1 in a DynamoDB row. The first time this is executed, the parameter does not exist, so it would be set to one. However, I want it to fail if it gets up to a specific value so it can only be updated so many times.
I am using the correct Expected syntax, but I can't seem to figure out a way to allow this currently without a double update: One to update if it's not there, and one do it if it is there and below the threshold. Is this possible in a single update command?
Please note, this is not the same thing as simply wanting a value to be set to 1 or add up from there as suggested in the comments below, but instead, this single expression must handle the property being there or a number, and then continue to add up a certain threshold, and then fail and not allow an update once the threshold is met.
Ok, I believe that this is possible, but only if you switch the whole update command over to using expressions instead of using the "Expected" and "AttributeUpdates" field. This does make it much harder to use, but then you should be able to make compound conditions such as
params.ConditionExpression = 'attribute_not_exists(#A) OR #A < ' + maxValue.toString();
I'm currently working on a non profit project where I need to reformat the way the data in the rows displays.
At the moment, this is how the row data looks:
Save The Children (Donation)|10.00{0}{2}
And I need it to output like this instead:
donation_id:save_children|quantity:1|total:10.00
The first problem is sometimes there's multiple items within the row:
Save The Children (Donation)|10.00{0}{2} / Save The Forrest|15.50{0}{2}
In which case it would need to be separated by a semicolon:
donation_id:save_children|quantity:1|total:10.00;donation_id:save_forrest|quantity:1|total:15.50
The second problem is, we have 9 donation variables/causes, each needing to convert the output to a different "donation_id".
So every time it finds:
Save the Children, it needs to convert to: donation_id:save_children
Save the Forrest, to, donation_id:save_forrest
Save the Animals, to, donation_id:save_animals
And so forth.
And the third problem is that the donation amounts are variable (as people donate whatever they wish), so the "total:" dollar value that we ouput will often be different.
How would I go about doing this with the regex?
Thank you
You can use below regex
(Save) The (Children|Forrest|Animals).*?\|([0-9]+\.[0-9]+)\{0\}\{2\}([\s\/]+)?
substitution/replace with
donation_id:$1_$2|quantity:1|total:$3;
When I test for
Save The Children (Donation)|10.00{0}{2} / Save The Forrest|15.50{0}{2}
Output is
donation_id:Save_Children|quantity:1|total:10.00;donation_id:Save_Forrest|quantity:1|total:15.50;
Test it online!
I'm trying to create a transformation read csv files and check data types for each field in that csv.
Like this : the standard field A should string(1) character and field B is integer/number.
And what I want is to check/validate: If A not string(1) then set Status = Not Valid also if B not a integer/number to. Then all file with status Not Valid will be moved to error folder.
I know I can use Data Validator to do it, but how to move the file with that status? I can't find any step to do it.
You can read files in loop, and
add step as below,
after data validation, you can filter rows with the negative result(not matched) -> add constant values step and with error = 1 -> add set variable step for error field with default values 0.
after transformation finishes, you can do add simple evaluation step in parent job to check value of ERROR variable.
If it has value 1 then move files else ....
I hope this can help.
You can do same as in this question. Once read use the Group by to have one flag per file. However, this time you cannot do it in one transform, you should use a job.
Your use case is in the samples that was shipped with your PDI distribution. The sample is in the folder your-PDI/samples/jobs/run_all. Open the Run all sample transformations.kjb and replace the Filter 2 of the Get Files - Get all transformations.ktr by your logic which includes a Group by to have one status per file and not one status per row.
In case you wonder why you need such a complex logic for such a task, remember that the PDI starts all the steps of a transformation at the same time. That's its great power, but you do not know if you have to move the file before every row has been processed.
Alternatively, you have the quick and dirty solution of your similar question. Change the filter row by a type check, and the final Synchronize after merge by a Process File/Move
And a final advice: instead of checking the type with a Data validator, which is a good solution in itself, you may use a Javascript like
there. It is more flexible if you need maintenance on the long run.
I'm not that great at python just getting snippets from here and there.
Right now I have user input, button click that runs the user's input and that is working for individual single inputs.
I am trying to make a user input with multiple answers
Example "1, 2, 5, 7, 23" -> To infinity amount
When submitted I need those answers to run in a loop until they are all used up.
So 5 answers would run the loop 5 times, each time using a different number from the user input.
By "each time using a different number" I mean I will be running a modbus coil command and those integers will be the coil address. Thus turning on or off those coils via the running loop.
So something like..
usernumbers = self.txtinput.get_text()
usernumbers.split()
usernumbersamount = len(usernumbers.split()
while usernumbers <= useramount:
modbus command goes here
Thats about as far as I can get of it will even work, Maybe it needs to be in an array for it to work?
sorry if user input looks funny this will be ran in a browser
Thanks!!
If the user separates the numbers using always the same character (space for instance) you can write:
usernumbers = self.txtinput.get_text()
for coil_address in [usernumbers.split()]:
self.run_coil_command(coil_address)
Change the split() by providing the separator used in you application: split(','), split(':'), ...
Normally we can use variable in imacro using SET tag, such as
SET myDelay 10
WAIT SECONDS={{myDelay}}
I need to know, is there any way to use 5-10 lines in a variable. Such as:
WAIT SECONDS=25
URL GOTO=........
WAIT SECONDS=15
SET !TIMEOUT_STEP 15
I want to use whole the above code in a variable. Cause i need to use those line many times in a macro script and i need to change also those lines. So its tough to change every line every time. If i could use a variable then it will easier for me to change only the variable and all the rest data will be working according to this variable.
OR if you have any idea how to do it?