Hitachi

JP1 Version 11 JP1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide 


10.3.33 getCsvColumn (gets a column in consideration of blank line of CSV data)

Syntax

getCsvColumn  [-c column] [-d] [file-path-name]

Description

This command outputs the column of the CSV file specified for the argument.

Arguments

-c column

This command outputs the data of the specified column. Specify a value not less than 1 for column. If this option is not specified, data for all column is output.

-d

Delete a blank line and outputs data.

file-path-name

This command specifies the path of the CSV file. If you do not specify the file path name, input from the standard input.

The size of CSV data that can be input is 100KB or less. If you input data larger than 100KB, the execution time of the job may become longer.

Return codes

Return code

Meaning

0

Normal termination

Not less than 1

Termination with an error

Notes

A value of more than 1 can be specified for column of argument, but whether the character string can be specified is not verified.

Examples

CSV data(data.csv)
name,value,id

Yokohama,200,1
Kawasaki,100,2

# Outputs data at the first column.
getCsvColumn -c 1 data.csv
#The following contents are output:
name

Yokohama
Kawasaki

#Outputs data that the blank line is deleted from the first column.
getCsvColumn -c 1 -d data.csv
# The following contents are output:
name
Yokohama
Kawasaki

# Outputs data that the blank line is deleted from the first line.
"${ADSH_DIR_CMD}awk" '{if(FNR!=1){print $0}}' data.csv | getCsvColumn -d
# Outputs the following contents:
Yokohama,200,1
Kawasaki,100,2