2

Does anyone know how to select a random N items from a feed in Yahoo Pipes?

I have an RSS feed that has a larger number of objects in it than the photo frame it's destined for can handle. I'm trying to use Yahoo Pipes to collect three of these feeds, combine them and then select 30 random items from the combination of all three feeds. Each time the feed is requested via Yahoo Pipes, I'd like a different set of random images to be selected.

In Yahoo Pipes, I can successfully combine the three feeds and I can use tail or truncate to chop it to only a certain number of items, but I don't want the first N or last N, I want a random set of items.

Any ideas how to do this?

jfriend00
  • 683,504
  • 96
  • 985
  • 979

1 Answers1

2

One strong possibility I can guess is to first build all the items out of which random items are to be selected. Using a csv module inside loop module with named columns (as result will not contain a column name call random number generators ( for example http://www.random.org/integers/?num=1&min=0&max=15&col=1&base=10&format=plain&rnd=new will generate a number between 0-15) and store the number received.

Then arrange in items in ascending or descending order of numbers received. If you need 'N' random items truncate the feed after 'N' items. Result will be a random feed.

Jalaj Jha
  • 109
  • 1
  • Sounds like a possibility. Do you have any pointers to an example pipe that does something like this. I'm new to Yahoo Pipes and don't know loops, csv modules, named columns, etc... – jfriend00 Oct 18 '11 at 06:27
  • will update you with example.. at this moment Yahoo Pipes is having some issue due to which all pipes are missing/non-working – Jalaj Jha Oct 18 '11 at 12:14
  • I looked into this and it looks like it would take a call to random.org for every item in each RSS feed, everytime the Yahoo Pipe feed was generated. That's a lot of calls to random.org and probably not very fast either. May run the risk of getting locked out of random.org. – jfriend00 Oct 18 '11 at 21:29
  • 1
    Random.org indeed seems to be blocking calls from Yahoo Pipes, but if the call is made through a proxy it does function properly for just the first item. So better host a simple php script somewhere which will look like For demonstration of how things would have worked if random.org worked fine see this pipe http://pipes.yahoo.com/pipes/pipe.info?_id=95d9da00f9b01389563a6e966310c7e1 since the source feed is just 7 items long I have truncated it at 5 – Jalaj Jha Oct 21 '11 at 07:24
  • this example no longer works. The fetch csv call only happens on the first iteration of the loop. – chovy Jan 04 '15 at 03:09