Thursday, September 1, 2011

Router Transformation Groups

Router Transformation's Groups are not the same as CASE statement conditions or what you may also call waterfall logic.

Router transformation routes data to all the groups that evaluate to TRUE unlike the CASE statement that executes the code only for the first true condition.

Wednesday, August 31, 2011

Awk one liner IF

Here is a quick one liner AWK for field comparison.

awk -F, '{if ($(1)=="0") {print $1}}' myfilename
What does it do?
From the comma separated file every record with first field as zero is printed.

It's important to keep parentheses as indicated. Although "print $1" is good; "if $1" poops.

Wednesday, July 6, 2011

Python - All Set for Comparison

I spent entire evening looking for a way to sort the characters in a string and figured it out.
  1. Turn the String into List. 
  2. Sort it. 
  3. Join it back as a String.
And then, I stumbled upon a better way to do string comparison. Convert them to sets!!!
set(stringA).difference(stringB)

Note that it may not be same as
set(stringB).difference(stringA)

Details on set theory here:

Discussion here:


Wednesday, June 22, 2011

BASH shell only - brace expansion

You might have used brace expansion if you have tried this very popular way of backing up files - 
cp filename{,.bk}

The command above will copy filename to filename.bk. It saves you from writing the filename again. 
This neat stuff is not compatible with korn shell.
Some other examples to reinforce how this works.

echo John{Doe,Smith}
  JohnDoe JohnSmith
echo {John,Jane}{Doe,Smith}
  JohnDoe JohnSmith JaneDoe JaneSmith
  

Note the lack of space after comma.

Wednesday, May 11, 2011

vi or sed - Delete till end of line from pattern

Here's the regex that will match everything from the pattern until a newline is found.

Say you want to remove everything after "here" from this sample file.

code here    where?
code here   right here!
code here         look every where.
Used regex
s/here.*//
Explanation:
.*  
dot matches any character including spaces, numbers, alphabets but not new line.
asterisk matches any number of occurrences of a character

s/here.*/meow/ will result in

code meow
code meow
code meow

Monday, May 9, 2011

Shell script for multiple SED edits

Following shell script
1.    Reads the names of the files to be edited from the file "filelist".
2.    Executes two sed statements on each of those files and
3.    Overwrites the original file. 


#!/usr/bin
while read line
do
sed 's/0512/0505/g' $line > temp
sed 's/05\/13/05\/06/g' temp > $line
done < filelist 

Saturday, April 2, 2011

Creating SQL statement for a Target Definition

I learned two things -
1. Don't blindly believe when people say it can't be done.
2. Informatica lets you create SQL statement to create target table.

I've been working to load this massive VSAM file with more than 1500 fields. Creating the source definition from the COBOL copybook was simple but creating ORACLE table manually for these many fields dampened my spirits.

I asked one of the more senior guys around here if he knew how to do it since he has been working on the same project with me. He said it wasn't possible and that I needed to do it manually.

I came back crushed and started reading Informatica Manual to delay my nemesis (so dramatic but seriously 1500 fields!).

It's then I learned that once the target definition has been created, Target Designer lets you "Generate/Execute SQL" for the target. BINGO! I was done in 2 minutes.

PS - To create target definition, I just dragged and dropped the source definition to target designer.