gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
303 stars 99 forks source link

Managment of CSV file #638

Closed pcaillou closed 9 years ago

pcaillou commented 9 years ago
What steps will reproduce the problem?
1. I produced a toy csv file from Excel and convert it into a csv.file : 
Nom;Prenom;age
B;G ;456
D;FF;234
D;FER;3456
2. When I read it on my GAMA model with : 
    file data <- file('../includes/mat.csv');
I get a matrix with 4 columns.
It is due to the fact that the second line contains "B ".
When I remove the space, I get 3 columns as expected.

Please use labels and text to provide additional information.

GAMA SVN MACOSX

Original issue reported on code.google.com by benoit.gaudou on 2013-09-16 13:51:24

pcaillou commented 9 years ago
Well. Yes. The specs of the CSV format are VERY fuzzy. And the regular CSV pattern (if
such a thing exists) recognizes space as a separator… However, I added, some time ago,
for the purpose of saving the population browser, a nice and simple CSV library. 

I have committed a version that uses their CSVReader. Can you check it ? I have no
time to do it right now, so tell me if it works better. To enable it,  I have added
a very simple operator "as_csv", that, applied to a text file, can take a string in
argument specifying the separator to use. You can test it like this :

file data <- file('../includes/mat.csv') as_csv ";"; (or as_csv "," if you want the
comma to be used).

and you can do the regular things (matrix, etc. ) normally after. If no separator is
provided, then the old algorithm is used (in order not to break models). 

If you assess this solution, please close the issue.

Original issue reported on code.google.com by alexis.drogoul on 2013-09-16 19:41:08

pcaillou commented 9 years ago
Any (good) news ? I will soon freeze the configuration of GAMA for the 1.6 release and
need to know whether or not to include this patch.

Original issue reported on code.google.com by alexis.drogoul on 2013-09-17 03:44:33

pcaillou commented 9 years ago
(No text was entered with this change)

Original issue reported on code.google.com by alexis.drogoul on 2013-09-17 08:06:47

pcaillou commented 9 years ago
OK. I close this one since the introduction of the as_csv operator seems to help dealing
with ambiguous CSV files (where several "official" separators coexist). 

Original issue reported on code.google.com by alexis.drogoul on 2013-09-17 11:29:21