All Topics | Topic: “Reading from a random year in a CSV file”
Author Message
Mr. Jack Sieber
Subject: Reading from a random year in a CSV file   
Posted: 10/3/2011 Viewed: 30916 times

There may be cases where you want to read a randomized sequence of data from a CSV file. You can use WEAP's built-in pseudo-random functions for this. (In this case, we will use the function RandomInteger.)

For example, assume your historical data file ("Flows.csv") had data for the years 1950-1999. First, Create a key assumption called RandomDataYear and set it equal to

If(TS = 1, RandomInteger(1950, 1999), PrevTSValue)

This will give a random year between 1950 and 1999, which will be different for each year of RandomDataYear. There may be duplicates.

Then, to read a random year from Flows.csv, use this expression:

ReadFromFile(Flows.csv, , \Key\RandomDataYear – Year)

Topic: “Reading from a random year in a CSV file”