1
1
/*******************************************************************************************************
2
2
*
3
- * CSVSaver.java, in msi.gama.core, is part of the source code of the GAMA modeling and simulation platform (v.1.9.2 ).
3
+ * CSVSaver.java, in msi.gama.core, is part of the source code of the GAMA modeling and simulation platform (v.2.0.0 ).
4
4
*
5
5
* (c) 2007-2023 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
6
6
*
7
- * Visit https://github.com/gama-platform/gama for license information and contacts.
7
+ * Visit https://github.com/gama-platform/gama2 for license information and contacts.
8
8
*
9
9
********************************************************************************************************/
10
10
package msi .gaml .statements .save ;
23
23
import msi .gama .runtime .exceptions .GamaRuntimeException ;
24
24
import msi .gama .util .GamaListFactory ;
25
25
import msi .gama .util .IList ;
26
+ import msi .gama .util .file .csv .AbstractCSVManipulator ;
26
27
import msi .gama .util .matrix .GamaMatrix ;
27
28
import msi .gaml .descriptions .SpeciesDescription ;
28
29
import msi .gaml .expressions .IExpression ;
@@ -144,12 +145,12 @@ private void save(final IScope scope, final Writer fw, final boolean header, fin
144
145
}
145
146
if (itemType .id () == IType .MATRIX ) {
146
147
GamaMatrix <?> matrix = (GamaMatrix ) value ;
147
- matrix .rowByRow (scope , v -> fw .write (toCleanString (v )), () -> fw . write ( "," ),
148
- () -> fw .write (Strings .LN ));
148
+ matrix .rowByRow (scope , v -> fw .write (toCleanString (v )),
149
+ () -> fw .write (AbstractCSVManipulator . getDefaultDelimiter ()), () -> fw . write ( Strings .LN ));
149
150
} else {
150
151
final int size = values .size ();
151
152
for (int i = 0 ; i < size ; i ++) {
152
- if (i > 0 ) { fw .write (',' ); }
153
+ if (i > 0 ) { fw .write (AbstractCSVManipulator . getDefaultDelimiter () ); }
153
154
fw .write (toCleanString (values .get (i )));
154
155
}
155
156
}
@@ -172,6 +173,7 @@ private void save(final IScope scope, final Writer fw, final boolean header, fin
172
173
* @return the string
173
174
*/
174
175
private String toCleanString (final Object o ) {
176
+ // Verify this (shouldn't we use AbstractCSVManipulator.getDefaultDelimiter() ?)
175
177
String val = Cast .toGaml (o ).replace (';' , ',' );
176
178
if (val .startsWith ("'" ) && val .endsWith ("'" ) || val .startsWith ("\" " ) && val .endsWith ("\" " )) {
177
179
val = val .substring (1 , val .length () - 1 );
0 commit comments