From: John Darrington Date: Tue, 1 Mar 2016 18:28:20 +0000 (+0100) Subject: DATA LIST: Do not treat the comma as a field separator if DECIMAL=COMMA X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=3eabe1e0eed831505e878deb41a283f489a33f2d DATA LIST: Do not treat the comma as a field separator if DECIMAL=COMMA Closes bug #47253 --- diff --git a/NEWS b/NEWS index dde55318f7..4236ae1754 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,9 @@ Changes from 0.8.5 to 0.9.0: * The GRAPH command now has a /BAR subcommand to draw barcharts. + * If the DECIMAL character is set to COMMA then the ',' character + will not be treated as a separator by DATA LIST. + * The graphical user interface (psppire) has been changed as follows: - It now uses Gtk+ version 3 instead of version 2. Accordingly, it has a diff --git a/doc/data-io.texi b/doc/data-io.texi index e1eeff09a3..cd0fc6386b 100644 --- a/doc/data-io.texi +++ b/doc/data-io.texi @@ -484,7 +484,10 @@ where each @var{var_spec} takes one of the forms @end display In free format, the input data is, by default, structured as a series -of fields separated by spaces, tabs, commas, or line breaks. Each +of fields separated by spaces, tabs, or line breaks. +If the current @subcmd{DECIMAL} separator is @subcmd{DOT} (@pxref{SET}), +then commas are also treated as field separators. +Each field's content may be unquoted, or it may be quoted with a pairs of apostrophes (@samp{'}) or double quotes (@samp{"}). Unquoted white space separates fields but is not part of any field. Any mix of diff --git a/doc/utilities.texi b/doc/utilities.texi index ea7f555ebb..2d22f2bba7 100644 --- a/doc/utilities.texi +++ b/doc/utilities.texi @@ -517,6 +517,8 @@ Setting it to @subcmd{DOT} causes the decimal point character to be Setting it to @subcmd{COMMA} causes the decimal point character to be @samp{,} and the grouping character to be @samp{.}. +If the setting is @subcmd{COMMA}, then @samp{,} will not be treated +as a field separator in the @cmd{DATA LIST} command (@pxref{DATA LIST}). The default value is determined from the system locale. @item FORMAT diff --git a/src/language/data-io/data-list.c b/src/language/data-io/data-list.c index f68b2e1b4d..90d060eaab 100644 --- a/src/language/data-io/data-list.c +++ b/src/language/data-io/data-list.c @@ -229,7 +229,9 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds) data_parser_set_quotes (parser, ss_cstr ("'\"")); data_parser_set_soft_delimiters (parser, ss_cstr (CC_SPACES)); - data_parser_set_hard_delimiters (parser, ss_cstr (",")); + const char decimal = settings_get_decimal_char (FMT_F); + data_parser_set_hard_delimiters (parser, + ss_buffer (",", (decimal == '.') ? 1 : 0)); } } } diff --git a/tests/language/data-io/data-list.at b/tests/language/data-io/data-list.at index b70e3904f5..b758411687 100644 --- a/tests/language/data-io/data-list.at +++ b/tests/language/data-io/data-list.at @@ -350,3 +350,37 @@ d,DATETIME17.0 f,F1.0 ]) AT_CLEANUP + +AT_SETUP([DATA LIST Decimal comma]) +AT_DATA([data-list.sps], [dnl +SET DECIMAL=COMMA. + +DATA LIST NOTABLE LIST /A *. +BEGIN DATA +1 +2 +3 +3,5 +4 +4,5 +5 +6 +END DATA + +LIST /FORMAT=NUMBERED. +]) + +AT_CHECK([pspp -O format=csv data-list.sps], [0], [dnl +Table: Data List +Case Number,A +1,"1,00" +2,"2,00" +3,"3,00" +4,"3,50" +5,"4,00" +6,"4,50" +7,"5,00" +8,"6,00" +]) + +AT_CLEANUP