DATA LIST: Do not treat the comma as a field separator if DECIMAL=COMMA
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 1 Mar 2016 18:28:20 +0000 (19:28 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 1 Mar 2016 18:28:20 +0000 (19:28 +0100)
Closes bug #47253

NEWS
doc/data-io.texi
doc/utilities.texi
src/language/data-io/data-list.c
tests/language/data-io/data-list.at

diff --git a/NEWS b/NEWS
index dde55318f761d04b19f25ef3878c02f0b4268050..4236ae1754d12df1e8fd02e2164a6e40e9329e0a 100644 (file)
--- 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 
index e1eeff09a37d1876eacc2fb4c269f84a0f21d617..cd0fc6386bae2ea99fecfbd8a40c2c5c1451435a 100644 (file)
@@ -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
index ea7f555ebb410d0fc9208cb41e6640d28a33c02f..2d22f2bba77763eb1757444e9345a33b0bd25bee 100644 (file)
@@ -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
index f68b2e1b4d058e2f71585b5742d8ad98e1baa8dc..90d060eaab66721a8462fcb81baa351494177441 100644 (file)
@@ -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));
                 }
             }
         }
index b70e3904f516880dc8e97d33bf21c2a91982d0bb..b7584116873efcf9a19c25972883819bbcf6a82c 100644 (file)
@@ -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