iterate over csv files in directory folder

47 views
Skip to first unread message

Chris Harvey

unread,
Feb 28, 2019, 9:02:07 AM2/28/19
to GAMA
Hello Everyone,

I'm having trouble with a bit of code. I have time series data which is quite large, so I broke it into three separate .csv files in the directory. I would like to initialize the simulation with the first file and upon reaching the end of that file, I would like to replace that .csv file with the next one in the folder. I would like to iterate like this until the end of the files. The code I've written is not working is not working and I'm looking for the correct way to do this. My code is as follows:

global
{

list<files>salFiles <- [sal2.csv, sal3.csv];
matrix data <- "../includes/Salinity/Sal1.csv";


action updateSal_File
{
loop U from: 1 to: 2 //loop over the rest of salinity files in folder
{
my_SalFile <- ".../includes/Salinity/string(U); //assign the next file to variable
matrix data <- matrix(my_SalFile); //convert file to matrix
}

}

reflex updateSalFile when: (cycle = length(data.columns)-1 ) //when cycle equals the length of salinity file
{
do updateSal_File(); //update salinity file
}


}

Patrick Taillandier

unread,
Feb 28, 2019, 12:52:10 PM2/28/19
to gama-p...@googlegroups.com
Hi,

Please find attached a possible solution to your problem.

Cheers,

Patrick

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at https://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.
test.zip
Reply all
Reply to author
Forward
0 new messages