Enhance SAM with features tailored to your specific needs! We collaborate with companies, universities, and organizations to privately fund new capabilities or analyses. Your investment drives innovation while benefiting the broader energy community. Email us to learn more.

Outputting result matrix using SamUL to excel

  • cosmith57
  • Topic Author
More
19 Dec 2014 15:00 #2863 by cosmith57
After making a matrix of data, I want to save it into a csv excel file. But when I do, the indices are ignored. For example:

data[0,0]=3
data[0,1]=-2
data[1,0]=5
data[1,1]=1
WriteTextFile("/Users/cp....csv",data)

Returns 3 -2 5 1 in my excel sheet (each number in a different column in row 1).

Is there not a way to write data matrices to excel? (Using a Mac)

Please Log in or Create an account to join the conversation.

  • Paul Gilman
More
22 Dec 2014 11:13 #2864 by Paul Gilman
Replied by Paul Gilman on topic Outputting result matrix using SamUL to excel
Hello, WriteTextFile() writes a string to the file.
Here's SamUL script that should work (Note that in SAM 2014.11.24, LK replaces SamUL):
data[0,0]=3

data[0,1]=-2

data[1,0]=5

data[1,1]=1
n_rows = length(data)

n_cols = length(data[0])
str_data = ""

str_row = ""
for (i=0;i

Please Log in or Create an account to join the conversation.

Moderators: Paul Gilman
Powered by Kunena Forum