Bulk CSV Exports

3 posts / 0 new
Last post
Bulk CSV Exports

I have a mess of projects I'm modeling. I would like to export the summary, monthly, and annual data tables to csv for all the projects in bulk. All in one go instead of going from project to project and exporting each one by hand. Is it possible to script this in SAM? In case anyone's curious, I'm working up evaluations for several parcels of land in a small city. I want to get this all into something like R or Excel. I'm using R to make some prettier plots than SAM can do. Excel makes it easier to format tables for insertion into a written report.

Paul Gilman


SAM's LK scripting language has functions exporting data that might be useful, but that works from within a project (.sam) file. If the files for each project are the same except for a few input variables, it would be fairly straight forward to create a case in a SAM file and then write a script to run each project and export results to a CSV file. The pseudocode would look something like

For each project:
Set value of inputs.
Run a simulation.
Write results to CSV file.

You could also write a program or script in C, Python, Java, or one of the other languages supported by the SAM Software Development Kit (SDK) to run the simulations and write the data to CSV without using the desktop version of SAM. The desktop version of SAM includes a code generator that you can use to generate code for the SDK from a case in SAM -- that way you can set up a project in SAM, generate the code, and then modify it to make the model runs you need.

Best regards,



Did you ever make any progress with this? I have a similar project with 15 to 20 buildings that this would be really handy on. I have been learning Python and would be happy to contribute towards a shared script.


Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer