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 "How to easily export many results using a script"
Log in to post new messages or reply to existing messages.
 
Author Message
Mr. Jack Sieber

Subject: How to easily export many results using a script   
Posted: 5/7/2015 Viewed: 20128 times
Here's how to automate the export of many different result for many scenarios. First, you need to save as Favorites the tables you want to export, making sure that scenario is NOT the legend or X axis dimension. Once the favorites exist, you can run a script, using the WEAP API, to export the favorites for all scenarios to CSV files. Look in the help under Advanced Topics, Automating WEAP for information about the API and scripting.

I would look something like this:

File: ExportResults.vbs

Set WEAP=CreateObject(“WEAP.WEAPApplication”)

' Make sure WEAP is fully started
While Not WEAP.ProgramStarted
Sleep (1)
Wend

For Each S in WEAP.Scenarios
  If Not S.IsCurrentAccounts Then
    CALL WEAP.LoadFavorite("Groundwater Storage")
    WEAP.ResultView("Scenario") = S.Name
    CALL WEAP.ExportResults("GW_" + S.Name + ".CSV", TRUE, TRUE)

    CALL WEAP.LoadFavorite("Unmet Demand")
    WEAP.ResultView("Scenario") = S.Name
    CALL WEAP.ExportResults("Unmet Demand_" + S.Name + ".CSV", TRUE, TRUE)
  End If
Next


Dr. Soroosh Alahdin

Subject: Re: How to easily export many results using a script   
Posted: 7/17/2015 Viewed: 19773 times
hi very dear jack
i noticed when the demand site are more than 12, in Results, the rest i mean the 13th, 14 th, ... are shown as ALL OTHERS, and in automation, i cannot go to the window and choose them manually, is there any way to show them directly so the exportation will be complete?
Dr. Soroosh Alahdin

Subject: Re: How to easily export many results using a script   
Posted: 7/17/2015 Viewed: 19756 times
hi again
I have to mention that "exportresults" give only the active results table, so when exporting, I miss the 13th and 14th.
and also because I am in a script I cannot make them active manually.
thanks
Dr. Soroosh Alahdin

Subject: Re: How to easily export many results using a script   
Posted: 7/17/2015 Viewed: 19749 times
hi
can the scenario explorer table be also exported in scripting mode?
Mr. Jack Sieber

Subject: Re: How to easily export many results using a script   
Posted: 7/17/2015 Viewed: 19741 times
Click the "Grp" button on the chart toolbar (to the right of the chart) to toggle between grouping

If there are more than 12 items in the results legend, you can click the Grp button to group the smallest items together into "All Others." You can change this setting in a script:

WEAP.ResultView("Group") = True

It is not possible to export the Scenario Explorer table in a script (via the WEAP API).

Jack

Dr. Soroosh Alahdin

Subject: Re: How to easily export many results using a script   
Posted: 7/20/2015 Viewed: 19699 times
another question
is rhere anyway that i can export two tables (in addition to active table)with exportresult command?
Mr. Jack Sieber

Subject: Re: How to easily export many results using a script   
Posted: 7/22/2015 Viewed: 19692 times
If you call ExportResult when WEAP is in the Scenario Explorer view, it will export all of the tables in the overview to one CSV file.
Mr. Michael Mutz

Subject: Re: How to easily export many results using a script   
Posted: 5/11/2018 Viewed: 10157 times
I have a question with regards to the setting of the group option. I'm using pywin32 for controlling WEAP:

import win32com.client

weap = win32com.client.Dispatch("WEAP.WEAPApplication")


however, once I loaded the area, if I try to set the group option by:

weap.ResultView("Group") = False

I get

SyntaxError: can't assign to function call


also, if I try to to
weap.ResultView("Group")

WEAP throws an error:
WEAPApplication.ResultView: This feature is not implemented.

What's going wrong here?

I'm using the most recent version of WEAP. Is it perhaps not the correct function, since a scenario called "Group" would then lead to an error?






Dr. Soroosh Alahdin

Subject: Re: How to easily export many results using a script   
Posted: 5/13/2018 Viewed: 10142 times
Dear michael
It would be better to do the setting with group button in the weap.
What ever your client program is(matlab or python)it is easier to change the setting in the righthand side toolbar and grp button.
Mr. Jack Sieber

Subject: Re: How to easily export many results using a script   
Posted: 5/13/2018 Viewed: 10140 times
I do not know why it is not working in Python. I just tried it again in Visual Basic Scripting (VBS) and it worked fine. Do you have problems setting other ResultView properties?

Jack
Topic "How to easily export many results using a script"