On Sat, 14 Jun 2014, Pindar wrote:
I programmed a function that uses getline and sscanf to parse
several internet time series from a string at ones.
To do so I replace the comma in decimal characters with a dot.
This is working when gretl is set on English. If I now turn to
German because I need the csv output option (which is
unfortunately only present when set to German) then the doubles
are either made to integers or when using commas no import happens
at all.
There is a bug here (more below) but the short answer is: use
set force_decpoint on
and then gretl in German will behave in the same way as gretl in
English with regard to sscanf. In addition, if you really, really
want to output a "csv" file with decimal commas when running gretl
in English (something that is not at all recommended, and therefore
is not made easy), consider this example:
<hansl>
open data4-1
set csv_delim semicolon
store horrid.csv
string s = readfile("horrid.csv")
s = strsub(s, ".", ",")
outfile horrid.csv --write
printf "%s", s
outfile --close
</hansl>
OK, here's the bug mentioned above. What happens if you trying using
sscanf on numerical values that use the decimal comma, when running
gretl in German (or any locale that uses the decimal comma), without
doing "set force_decpoint on"? You might expect that either (a)
you'd get the same effect as when running in English (truncation to
integer) or else (b) you'd get the full numerical value. But up till
now you'd in fact get an error condition. Bug!
For the present I've "fixed" this (in CVS) such that you get the
full numerical value, but I'm not at all sure that's right. That
needs further discussion.
Allin