Sponsored Content
Top Forums Shell Programming and Scripting Want to implement VLOOKUP (Excel function) in Unix Post 302194881 by pravani1 on Wednesday 14th of May 2008 12:14:41 AM
Old 05-14-2008
MySQL Want to implement VLOOKUP (Excel function) in Unix

Dear All,

i want to implement vookup function which is there in excel into Unix. Suppose i have 2 files. The files are given below.

File1:
Code:
MSC	             Cell	SDCA
Patna-1	             12	Bihar
Patna-2	             45	Ranchi
Bhopal-1	             85	Raigarh
Bhopal-2	             66	Indore
Mumbai-1	78	Turbhe
Mumbai-2	25	Nashik
Mumbai-3	45	Dhule

& File2:
Code:
MSC		New MSC
Patna-1		Patna1
Patna-2		Patnaomp2
Bhopal-1	             bhopal
Bhopal-2	             bhopal2
Mumbai-1	mum1
Mumbai-2	mumomp2
Mumbai-3	mum3

The required output must like this:
Code:
result
MSC		Cell	SDCA
Patna1		12	Bihar
Patnaomp2	45	Ranchi
bhopal		85	Raigarh
bhopal2		66	Indore
mum1		78	Turbhe
mumomp2	25	Nashik
mum3		45	Dhule

Please help me for the same.

Thank u

Last edited by Yogesh Sawant; 05-14-2008 at 02:18 AM.. Reason: added code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

VLOOKUP utility in UNIX

Kindly help me to build the script similar to VLOOKUP function of MS Excell. (5 Replies)
Discussion started by: hjoshi
5 Replies

2. Programming

How to implement polling for a function using timer in C?

Hi, Can you please help me in implementing a timer based polling for function in C? ie. the function should be called in say 30secs(when 30secs has lapsed). Thanks (7 Replies)
Discussion started by: naan
7 Replies

3. Shell Programming and Scripting

Help require for vLookup Utility same as in EXCEL

Hi guys, can someone please help me with a vlookup utility in shell script that does the work similar to Excel. Ex: If File1.txt is 1 2 11 4 12 and File2.txt is 1 tab1 2 tab2 3 tab3 4 tab4 5 tab5 then the utility should create File3.txt with the below mentioned output: (24 Replies)
Discussion started by: viveklgupta007
24 Replies

4. UNIX for Dummies Questions & Answers

Implement the '&&' function in a shell

Hello, I'm currently implementing the && function in a shell using C. For example, if we input cmd1 && cmd2, then cmd2 executes only when cmd1 exits successfully. I'm thinking about: int main() { int i; char **args; while(1) { printf("yongfeng's shell:~$ "); args =... (5 Replies)
Discussion started by: Yongfeng
5 Replies

5. Shell Programming and Scripting

awk script to perform an action similar to vlookup between two csv files in UNIX

Hi, I am new to awk/unix and am trying to put together an awk script to perform an action similar to vlookup between the two csv files. Here are the contents of the two files: File 1: Date,ParentID,Number,Area,Volume,Dimensions 2014-01-01,ABC,247,83430.33,857.84,8110.76... (9 Replies)
Discussion started by: Prit Siv
9 Replies

6. UNIX for Dummies Questions & Answers

Command for vlookup function

Hello experts, I have large text files that need to be arranged using a function like excel's vlookup. I have been playing with awk command but didn't really come up with a solution. Could anyone please help me out? Below are my datasets and expected output. Any help would be greatly... (8 Replies)
Discussion started by: makelifeeasier
8 Replies

7. Shell Programming and Scripting

Trying to implement count_collatz_step function

Can anyone give me a clue why this code doesn't work as expected? The function count_collatz_step() take one parameter which a number that need to calculate collatz until it reaches 1. The func should return steps it takes. # # Count steps of collatz conjecture takes, until the number reach 1.... (8 Replies)
Discussion started by: Bunchhieng
8 Replies

8. Shell Programming and Scripting

Excel vlookup function like value mapping with awk

I have two files File1 175552 st_497858.1 rs86052.1 rs92185.1 st_001022416.1 174841 175552_174841 179912 st_001122967.2 rs90435.1 rs89122.1 st_001022583.1 175545 179912_175545 179912 st_001122967.2 rs90435.1 rs89122.1 st_001022584.1 175545 179912_175545 179967 st_001256606.1 rs93516.2... (1 Reply)
Discussion started by: sammy777888
1 Replies

9. UNIX for Beginners Questions & Answers

Vlookup on 2 files - inserting vlookup command on another command

Hello, i am trying to print group name column(etc/group) on script (etc/passwd) since group name is not listed on etc/passwd columns. Im trying to do a vlookup. but i cant figure out how i can insert the vlookup command FNR==NR inside the print out command or the output. I also tried exporting... (2 Replies)
Discussion started by: joonisio
2 Replies

10. UNIX for Beginners Questions & Answers

How to compare two files in UNIX using similar to vlookup?

Hi, I want to compare same column in two files, if values match then display the column or display "NA". Ex : File 1 : 123 abc xyz pqr File 2: 122 aab fdf pqr fff qqq rrr (1 Reply)
Discussion started by: hkoshekay
1 Replies
Spreadsheet::XLSX::Utility2007(3pm)			User Contributed Perl Documentation		       Spreadsheet::XLSX::Utility2007(3pm)

NAME
Spreadsheet::XLSX::Utility2007 - Utility function for Spreadsheet::XLSX SYNOPSIS
use strict; #Declare use Spreadsheet::XLSX::Utility qw(ExcelFmt ExcelLocaltime LocaltimeExcel); #Convert localtime ->Excel Time my $iBirth = LocaltimeExcel(11, 10, 12, 23, 2, 64); # = 1964-3-23 12:10:11 print $iBirth, " "; # 23459.5070717593 #Convert Excel Time -> localtime my @aBirth = ExcelLocaltime($iBirth, undef); print join(":", @aBirth), " "; # 11:10:12:23:2:64:1:0 #Formatting print ExcelFmt('yyyy-mm-dd', $iBirth), " "; #1964-3-23 print ExcelFmt('m-d-yy', $iBirth), " "; # 3-23-64 print ExcelFmt('#,##0', $iBirth), " "; # 23,460 print ExcelFmt('#,##0.00', $iBirth), " "; # 23,459.51 print ExcelFmt('"My Birthday is (m/d):" m/d', $iBirth), " "; # My Birthday is (m/d): 3/23 DESCRIPTION
Spreadsheet::XLSX::Utility exports utility functions concerned with Excel format setting. ExcelFmt is used by Spreadsheet::XLSX::Fmt2007.pm which is used by Spreadsheet::XLSX. Functions This module can export 3 functions: ExcelFmt, ExcelLocaltime and LocaltimeExcel. ExcelFmt $sTxt = ExcelFmt($sFmt, $iData [, $i1904]); $sFmt is a format string for Excel. $iData is the target value. If $flg1904 is true, this functions assumes that epoch is 1904. $sTxt is the result. For more detail and examples, please refer sample/chkFmt.pl in this distribution. ex. ExcelLocaltime ($iSec, $iMin, $iHour, $iDay, $iMon, $iYear, $iwDay, $iMSec) = ExcelLocaltime($iExTime [, $flg1904]); ExcelLocaltime converts time information in Excel format into Perl localtime format. $iExTime is a time of Excel. If $flg1904 is true, this functions assumes that epoch is 1904. $iSec, $iMin, $iHour, $iDay, $iMon, $iYear, $iwDay are same as localtime. $iMSec means 1/1,000,000 seconds(ms). LocaltimeExcel $iExTime = LocaltimeExcel($iSec, $iMin, $iHour, $iDay, $iMon, $iYear [,$iMSec] [,$flg1904]) LocaltimeExcel converts time information in Perl localtime format into Excel format . $iSec, $iMin, $iHour, $iDay, $iMon, $iYear are same as localtime. If $flg1904 is true, this functions assumes that epoch is 1904. $iExTime is a time of Excel. col2int $iInt = col2int($sCol); converts a excel row letter into an int for use in an array This function was contributed by Kevin Mulholland. int2col $sCol = int2col($iRow); convert a column number into column letters NOET: This is quite a brute force coarse method does not manage values over 701 (ZZ) This function was contributed by Kevin Mulholland. sheetRef ($iRow, $iCol) = sheetRef($sStr); convert an excel letter-number address into a useful array address NOTE: That also Excel uses X-Y notation, we normally use Y-X in arrays $sStr, excel coord (eg. A2). This function was contributed by Kevin Mulholland. xls2csv $sCsvTxt = xls2csv($sFileName, $sRegion, $iRotate); convert a chunk of an excel file into csv text chunk $sRegions = "sheet-colrow:colrow" (ex. '1-A1:B2' means 'A1:B2' for sheet 1) $iRotate = 0 or 1 (output should be rotated or not) This function was contributed by Kevin Mulholland. AUTHOR
Rob Polocz rob.polocz@trackvia.com based on work by for Spreadsheet::ParseExcel by Kawai Takanori (Hippo2000) used with permission SEE ALSO
Spreadsheet::ParseExcel, Spreadsheet::WriteExcel COPYRIGHT
This module is part of the Spreadsheet::XLSX distribution. perl v5.10.1 2010-05-16 Spreadsheet::XLSX::Utility2007(3pm)
All times are GMT -4. The time now is 10:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy