- Posts: 3
SamUL - Writing multiple arrays in .csv file
- azanalo
- Topic Author
        Less
        More
        
            
    
        
            
        
                27 Mar 2013 22:18                #1482
        by azanalo
    
    
            
            
            
            
            
                                
    
                                                
    
        SamUL - Writing multiple arrays in .csv file  was created by azanalo            
    
        Hello everyone!
I started using SamUL this week, and I have a general question on what the correct "Write" function is for the following:
I created a "for" function to loop through all the tmy files in the /exelib folder located in my computer. Within each element of the loop I have a "while" function to calculate the LCOE for several inverter DC/AC ratios. In summary, the "while" loop will create two arrays, one for the LCOE and another one for the DC/AC ratio. The final goal is to plot these two variables together to find out what is the optimum DC/AC ratio. How can I write these two arrays in a .csv file such that Column A = LCOE and Column B = DC/AC Ratio? I tried the functions Write and WriteResults but I may be using them incorrectly, or maybe there's a better function for this.
Thank you so much in advance!
AZ
    
    I started using SamUL this week, and I have a general question on what the correct "Write" function is for the following:
I created a "for" function to loop through all the tmy files in the /exelib folder located in my computer. Within each element of the loop I have a "while" function to calculate the LCOE for several inverter DC/AC ratios. In summary, the "while" loop will create two arrays, one for the LCOE and another one for the DC/AC ratio. The final goal is to plot these two variables together to find out what is the optimum DC/AC ratio. How can I write these two arrays in a .csv file such that Column A = LCOE and Column B = DC/AC Ratio? I tried the functions Write and WriteResults but I may be using them incorrectly, or maybe there's a better function for this.
Thank you so much in advance!
AZ
Please Log in or Create an account to join the conversation.
- Paul Gilman
        Less
        More
        
            
    
        - Posts: 5665
            
        
                28 Mar 2013 14:22                #1483
        by Paul Gilman
    
    
            
            
            
            
            
                                
    
                                                
    
        Replied by Paul Gilman on topic SamUL - Writing multiple arrays in .csv file             
    
        Hello AZ,
I've had success creating an array of values of type String to store the entire contents of the CSV file, and then writing the array to the file using the WriteTextFile() function.
Best regards,
Paul.
    
    I've had success creating an array of values of type String to store the entire contents of the CSV file, and then writing the array to the file using the WriteTextFile() function.
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
- azanalo
- Topic Author
        Less
        More
        
            
    
        - Posts: 3
            
        
                28 Mar 2013 18:27                #1484
        by azanalo
    
    
            
            
            
            
            
                                
    
                                                
    
        Replied by azanalo on topic SamUL - Writing multiple arrays in .csv file             
    
        Thank you Paul!
I gave a try to your recommendation in the script below and I got very close. The only problem is that the array is written as a row, not as column which is what I want. Would you mind taking a quick look at it? Thanks.
My next step would be to add another column with the Array Size such that for each Array Size there's a LCOE associated. Will this possible with the WriteTextFile() function as well?
I know this script is kind of sloppy, so please don't laugh .
.
Thanks!
count = 5
for(i=0 ; i< count ; i=i+1)
SetInput("pv.array.desired_size",(i+1)*1000)
simulate()
LCOE_calc = GetOutput("sv.lcoe_nom")
Out(LCOE_calc + "\n")
LCOE = String(LCOE_calc) + "\n"
WriteTextFile("C:/Users/alvazano/Desktop/test.csv", LCOE_calc)
end
    I gave a try to your recommendation in the script below and I got very close. The only problem is that the array is written as a row, not as column which is what I want. Would you mind taking a quick look at it? Thanks.
My next step would be to add another column with the Array Size such that for each Array Size there's a LCOE associated. Will this possible with the WriteTextFile() function as well?
I know this script is kind of sloppy, so please don't laugh
 .
.Thanks!
count = 5
for(i=0 ; i< count ; i=i+1)
SetInput("pv.array.desired_size",(i+1)*1000)
simulate()
LCOE_calc = GetOutput("sv.lcoe_nom")
Out(LCOE_calc + "\n")
LCOE = String(LCOE_calc) + "\n"
WriteTextFile("C:/Users/alvazano/Desktop/test.csv", LCOE_calc)
end
Please Log in or Create an account to join the conversation.
- azanalo
- Topic Author
        Less
        More
        
            
    
        - Posts: 3
            
        
                28 Mar 2013 18:32                #1485
        by azanalo
    
    
            
            
            
            
            
                                
    
                                                
    
        Replied by azanalo on topic SamUL - Writing multiple arrays in .csv file             
    
        Mmmhhh, is there a Transpose function in SamUL by any chance? That would do it
Thanks!
Alvaro
    Thanks!
Alvaro
Please Log in or Create an account to join the conversation.
- Paul Gilman
        Less
        More
        
            
    
        - Posts: 5665
            
        
                29 Mar 2013 12:50                #1486
        by Paul Gilman
    
    
            
            
            
            
            
                                
    
                                                
    
        Replied by Paul Gilman on topic SamUL - Writing multiple arrays in .csv file             
    
        You might try something like the following:
BEGIN SCRIPT
count = 5
for(i=0 ; i
    BEGIN SCRIPT
count = 5
for(i=0 ; i
Please Log in or Create an account to join the conversation.
        Moderators: Paul Gilman    
 
  
 















