plumber!s toolbox

tips, tricks, techniques, and tools for yahoo! pipes
by alex ibrado
Apr 14

Counter (for loop)

A loop that counts from A to B is quite useful for the times when you need to repeat a certain operation X times.

This module is similar to Mauricio Scheffer’s, but uses an internal string for the number source instead of pulling in a CSV file from a remote host. By default, it’s limited to a max of 1000 loops as well, but you can just add more numbers.

To use this, clone it and drag into your editor from “My pipes” into a Loop where you embed your desired action. The counter is accessible as “item.i”. Note that the silly “+ 0” loop is a workaround for a bug in the String Tokenizer, where it tokenizes 0 to an empty string.

Here’s a bash one-liner to make more numbers. Just copy and paste the values into the String Builder.

limit=2000; (for ((i=0;i < $limit; ++i)); do echo -n $i; if [ $i -ne (( $limit-1 )) ]; echo -n , ’ ) > $limit-numbers.csv

pipes.yahoo.com/plumber/counter

« older    newer »

blog comments powered by Disqus