Welcome to WEAP's Website WEAP
WEAP is an initiative of the Stockholm Environment Institute.


About WEAP

Home
Why WEAP?
Features
What's New?
Sample Screens
Demonstration
Publications
History and Credits

Using WEAP
Download
Licensing
User Guide
Tutorial
Videos (YouTube)

User Forum
Discussions
Members List
Edit Profile

Additional Support
Training
University Courses
Collaboration

About Us
SEI-US Water Resources Program
Please Contact Us

LEAP
Interested in Energy?
Read about LEAP: SEI's software for energy planning.

Link WEAP and LEAP for combined Water-Energy planning.
Watch a video demo!
   

User Forum

All Topics | Topic "Reading from a random year in a CSV file"
Log in to post new messages or reply to existing messages.
 
Author Message
Mr. Jack Sieber

Subject: Reading from a random year in a CSV file   
Posted: 10/3/2011 Viewed: 27304 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"