dnl PSPP - a program for statistical analysis.
dnl Copyright (C) 2017 Free Software Foundation, Inc.
-dnl
+dnl
dnl This program is free software: you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation, either version 3 of the License, or
dnl (at your option) any later version.
-dnl
+dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
-dnl
+dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
-dnl AT_BANNER([SAVE TRANSLATE /TYPE=CSV])
+dnl
+AT_BANNER([SAVE TRANSLATE /TYPE=CSV])
m4_define([PREPARE_SAVE_TRANSLATE_CSV], [dnl
AT_KEYWORDS([SAVE TRANSLATE])
])
AT_CLEANUP
-AT_SETUP([CSV output -- KEEP, RENAME])
+AT_SETUP([CSV output -- KEEP, RENAME quoted])
PREPARE_SAVE_TRANSLATE_CSV(
- [/FIELDNAMES /KEEP=time string /RENAME string=name /UNSELECTED=DELETE])
+ [/FIELDNAMES /KEEP=time string /RENAME string='long name with spaces' /UNSELECTED=DELETE])
AT_CHECK([cat data.csv], [0], [dnl
-time,name
+time,long name with spaces
-05:17:00, xxx
12:00:00,xyzzy
])
AT_CLEANUP
+
+AT_SETUP([CSV output -- KEEP, RENAME multi quoted])
+PREPARE_SAVE_TRANSLATE_CSV(
+ [/FIELDNAMES
+ /RENAME =
+ number = "this one"
+ time = "that one"
+ date = "which one?"
+ datetime = "another variable replacement"
+ string="long name with spaces"
+ /UNSELECTED=DELETE])
+AT_CHECK([cat data.csv], [0], [dnl
+this one,that one,which one?,another variable replacement,long name with spaces,filter
+ ,-05:17:00,10/31/2010,04/09/2008 09:29:00, xxx,1
+1.625,12:00:00, , ,xyzzy,1
+])
+AT_CLEANUP
+
+
+AT_SETUP([CSV output -- KEEP, RENAME bad name ])
+AT_DATA([bad.sps], [
+data list notable list /Var1 Var2 Var3 Var4 Var5 *.
+begin data
+1 2 3 4 5
+end data.
+
+SAVE TRANSLATE
+/OUTFILE="foo.csv"
+ /TYPE=CSV
+ /MAP
+ /REPLACE
+ /FIELDNAMES
+ /Unselected=DELETE
+ /RENAME =
+ Var4 = foobar
+ (Var1 Var2 = one Var3 )
+ (Var3 = "The second")
+ /CELLS=VALUES
+.
+])
+
+AT_CHECK([pspp -O format=csv bad.sps], [1], [dnl
+"bad.sps:16: error: SAVE TRANSLATE: Cannot rename Var2 as Var3 because there already exists a variable named Var3. To rename variables with overlapping names, use a single RENAME subcommand such as `/RENAME (A=B)(B=C)(C=A)', or equivalently, `/RENAME (A B C=B C A)'."
+])
+
+
+AT_CLEANUP
+
+
+
AT_BANNER([SAVE TRANSLATE /TYPE=TAB])
AT_SETUP([TAB output])
1.625 12:00:00 xyzzy 1
])
AT_CLEANUP
+