how can I read a csv file as a matrix

109 views
Skip to first unread message

Suhad Faisal

unread,
Jul 2, 2014, 12:32:28 PM7/2/14
to
hello 

how can I read a csv file  or the species agents as a matrix, and deal with its data as data cell in matrix referenced by (i,j) ? 

cheers
suhad

Arnaud Grignard

unread,
Jul 3, 2014, 4:48:21 AM7/3/14
to gama-platform
Dear Suhad,

Before to ask this question, did you check the documentation of Gama and the already existing model in the library?

This model which is in Features/Data Importation is exactly doing what you want.

/**

 *  CSVfileloading

 *  Author: administrateur

 *  Description: Shows how to import a CSV file and use it

 */


model CSVfileloading


global {

file my_csv_file <- csv_file("../includes/iris.csv",",");

init {

matrix data <- matrix(my_csv_file);

loop i from: 1 to: data.rows -1{

loop j from: 0 to: data.columns -1{

write "data rows:"+ i +" colums:" + j + " = " + data[j,i];

}

}

}

}


experiment main type: gui{

}


Arnaud

On Wed, Jul 2, 2014 at 6:32 PM, Suhad Faisal <suha...@gmail.com> wrote:
hello 

how can I read a csv file as a matrix, and dell with its data as data cell in matrix referenced by (i,j) ? 

cheers
suhad

--
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 http://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.



--
http://arnoi69.tumblr.com/

Suhad Faisal

unread,
Jul 3, 2014, 4:54:22 AM7/3/14
to gama-p...@googlegroups.com
thank you very much , but as you know the reading had been forgotten after while, so just the practice is the key of all technical problems , that's why I'm asking the professional, cause you can give the useful point directly .

best regards 

suhad


--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/0hFUK-vwCMA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.

Benoit Gaudou

unread,
Jul 3, 2014, 6:20:43 AM7/3/14
to gama-p...@googlegroups.com
Hi,
I agree with the fact that practice is the key for learning, but also try-and-error and own research.
You have several tools for your research:
- the library of models (and in particular Features contain models sorted by themes)
- in GAMA itself, you have research functions that allow you to find relevant information in the library of models
- in the doc you have a sketch of index : https://code.google.com/p/gama-platform/wiki/G__Index
- and the whole doc

Benoit

Suhad Faisal

unread,
Jul 3, 2014, 8:23:25 AM7/3/14
to gama-p...@googlegroups.com
thank you , I will follow your advice, wishing to discuss with the experts continuously

cheers
suhad
Reply all
Reply to author
Forward
0 new messages