10.3.30 arrayToCsv (outputs a value of two-dimensional array to CSV data)
Syntax
arrayToCsv [-i] array-name
Description
This command outputs the two-dimensional array data specified for argument as CSV data. Each field of CSV data is enclosed with double quotation marks. Examples of support of two-dimensional array data and contents of output are as follows:
Data of two-dimensional array (array)
array[0][0]=name array[0][1]=value array[0][2]=id array[1][0]=Yokohama array[1][1]=200 array[1][2]=1 array[2][0]=Kawasaki array[2][1]=100 array[2][2]=2
Contents if data of two-dimensional array (array) is output
"name","value","id" "Yokohama","200","1" "Kawasaki","100","2"
If a double quotation mark is included in data of two-dimensional array, increase one double quotation mark before outputting data.
Example:
Data of two-dimensional array |
Data to be output |
---|---|
a"b"c |
"a""b""c" |
Arguments
- -i
-
If the field value is numerical value, no double quotation mark is provided when data is output.
Numerical values have the following syntax. Example: 123, -100, 001
[-]<Numeric characters>+
- array-name
-
This command specifies a name of two-dimensional array that outputs data.
Output to the standard output
Two-dimensional array data in the CSV format.
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
Not less than 1 |
Termination with an error |
Notes
-
Do not specify an array name starting with "adsh" for the array-name argument. If you specify such an array name, it might conflict with the name of another variable used within the part and produce invalid output.
-
The character string that can be specified for array-name is the same as character string that can be used as variable name. However, whether the character string can be specified is not verified.
Examples
set -D array { name value id } { Yokohama 200 1 } { Kawasaki 100 2 } arrayToCsv array # The following contents are output: "name","value","id" "Yokohama","200","1" "Kawasaki","100","2" set -D array { name value id } { Yokohama 200 1 } { Kawasaki 100 2 } arrayToCsv -i array # The following contents are output: "name","value","id" "Yokohama",200,1 "Kawasaki",100,2