Posted: Mon Nov 21, 2011 2:41 pm
Parse the comma-delimited field into separate columns using Transformer stage then use Pivot stage.
A short text to describe your forum
http://www.dsxchange.com/
I get this message when clicking any topic within the FAQ forum. Maybe it's just my ID having a problem.chulett wrote:
Eric, can you access it directly from the FAQ forum? It's almost at the bottom of the listed posts there.
Code: Select all
#!/usr/bin/ksh
###########################################################################
#
#
# Script Name: DynamicPivot.sh
#
#
# Input: DynamicPivot.sh {Input File Absolute Path}
#
#
# Output: Output File Absolute Path
# 0 - for success
# Error Description - for failure
#
#
# Description:
#
# This script gets executed on the command line, with
# one arguments (see Input).
# This will perform the dynamic pivoting mechanism.
#
# This will pivot the data of file having two fields
# one file which is key field(Not Nullable) and the other field(pivot field)
#
#
###########################################################################
###########################################################################
#
# Setting the standard variables
#
###########################################################################
PROG=`basename ${0}`
EXIT_STATUS=0
NOW=`date`
###########################################################################
#
# Check command line arguments
#
###########################################################################
if [ ${#} -ne 2 ]
then
echo "${NOW} ${PROG}: Invalid parameter list."
echo "${NOW} ${PROG}: The script needs 2 parameters:"
echo "${NOW} ${PROG}: Source File Absolute path and Target File Absolute path"
exit 99;
fi
INPUT_FILE_PATH=${1}
OUTPUT_FILE_PATH=${2}
cat /dev/null > ${OUTPUT_FILE_PATH}
while read i
do
field1=`echo ${i} | awk -F '|' '{print $1;}'`
cnt_fld2=`echo ${i} | awk -F '|' '{print $2;}' | awk -F ',' '{print NF;}'`
j=1
if [ cnt_fld2 -eq 0 ];then
echo ${field1}"|" >> ${OUTPUT_FILE_PATH}
else
while [ j -le ${cnt_fld2} ]
do
echo ${field1}"|"`echo ${i} | awk -F '|' '{print $2;}' | awk -F ',' -v name="$j" '{print $name;}'` >> ${OUTPUT_FILE_PATH}
j=`expr ${j} + 1`
done
fi
done < ${INPUT_FILE_PATH}
exit 0;
i dont understand this context. can you pls explain it?...the hashed file normalized on the multi-valued column.