[Gretl-users] CSV and decimal point character

Allin Cottrell cottrell at wfu.edu
Sat Nov 26 17:57:06 EST 2011

On Fri, 25 Nov 2011, Allin Cottrell wrote:

> On Fri, 25 Nov 2011, Allin Cottrell wrote:
>> On Fri, 25 Nov 2011, Henrique Andrade wrote:
>>> I´m trying to save data into comma-separated values (the csv extension) 
>>> files using the Brazilian standard (comma as the decimal point character) 
>>> but it is not working. Gretl only saves the text file with point as the 
>>> decimal point character. [...]
>> You don't want "set force_decpoint on" here, but something has indeed gone 
>> wrong: it seems you can't currently save CVS data using anything other than 
>> "." as the decimal character. (I'm not sure when that happened.)
> Correction: you can do this, but only via the GUI. When you choose to export 
> data as CVS under the /File menu, and the decimal "," is currently in force, 
> you get the option of setting "," as the decimal character in the CSV output 
> -- but it's never the default, which I
> think is correct.

On the principle that what you can do via the gretl GUI you should 
also be able to do via the gretl command line, here's what is now
available in CVS:

set csv_decimal_comma
store teste.csv

This will save a "CSV" file in which the decimal character is ',' 
(and the column separator is forced to ';').

However, I'm mostly in agreement with those who don't like use of 
anything other than '.' as the decimal character (except for display 
purposes) so let me hasten to add:

* The default is still to use '.' when saving data, even if the 
locale decimal character is ',' and the user has elected to use this 
character in display of gretl output.

* The new "set" command illustrated above is unusual in that it is 
not persistent (this is documented in CVS, not yet in the 
snapshots). That is, "set csv_decimal_comma" applies only to the 
next "store" command. If you want to save several files using the 
decimal comma you must issue the relevant "set" command each time. 
In other words, the decimal comma never becomes the default for 
saving data, even within a gretl script or session.

Allin Cottrell

More information about the Gretl-users mailing list