Tuesday, August 10, 2010

Unix file processing

This command is very useful to analyze data files

cut -d ' -f |

single col :
cut -d '|' -f1 uncl_sims_audit_clr_code_null.txt | sort|uniq

multiple cols
cut -d '|' -f1-2 uncl_sims_audit_clr_code_null.txt | sort|uniq


enjoy..!

Wednesday, July 7, 2010

Passing arrays to perl subroutines

Finally when we receive thes values in@_ variable then we can not recognize if we had passed one array or two value arraysbecause finally it is getting merged into one.
o

If you want to work with and identify the individual lists passed to Perl, then you need to use references:

(@listc, @listd) = simplesort(\@lista, \@listb);

The leading \ character tells Perl to supply a reference, or pointer, to the array. A reference is actually just a scalar, so we can identify each list by assigning the reference to each array within our subroutine. Now you can write your subroutineas follows:

sub simplesort
{
my ($listaref, $listbref ) = @_;

# De-reference the array list
my (@lista) = @$listaref;
my (@listb) = @$listbref;
# Now you can play with both arrays.
}

Wednesday, June 23, 2010

Syntax of inner join

select * from foo

inner join (

select 5 as bar

union all select 6

union all select 7

) as x on foo.bar = x.bar

Thursday, March 18, 2010

Change End of Line characters in eclipse

In Eclipse, go to window -> preferences -> workspace

In the bottom right handside of workspace, you will see,
New Text File Line Delimiter,
Click on other, and change it to Unix.

See Image below.



Cheers,
Sonu

Remove Ctrl M characters in vi

To remove windows end of line characters, Ctrl M characters in vi

1) open the file in vi
vi
2) Type the following
To get ^M, press ctrl key on your keyboard and press v and m

:%s/^M//g

3) dont forget to save the file with :wq!

Enjoy.

Monday, February 22, 2010

Forcing index- SQL

So if cust_num is the 6 th index created on the table. Here is how you force the index while querying the database table :

select * from tranhist (6) where cust_num='AA25150'

Thursday, February 18, 2010

Excel Printing header on each line

Goto File -> Page Setup -> goto sheet tab -> In Print Titles section, Rows to repeat at top, enter the range of rows you would like to repeat : $1:$1

http://www.mrexcel.com/tip129.shtml