![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script for Reading a Password file | srirams | Shell Programming and Scripting | 2 | 03-07-2007 07:20 AM |
| Script for reading an input file | gzs553 | Shell Programming and Scripting | 1 | 10-17-2006 03:55 AM |
| Reading file names from a file and executing the relative file from shell script | anushilrai | Shell Programming and Scripting | 4 | 03-10-2006 02:25 AM |
| script to reading a file | vasikaran | UNIX for Dummies Questions & Answers | 3 | 07-26-2005 02:28 AM |
| Reading a file into a C++ script | Breen | High Level Programming | 1 | 10-08-2003 03:04 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Script for reading .csv file
Can someone please help me to write script for following scenario :
1> script should read a input .csv file of format : EmpName, PF, Leave, Basic ,HRA 2> another config file ( may be again a .csv file ) has format EmpName and EmpID 3> script should read another config file for each EmpName in the input file , to find the EmpID 4> After finding EmpID from config file, all records need to be written in 3rd file ( output file ) with format : EmpName ,EmpID ,PF, Leave ,Basic ,HRA Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Here's something to start with.
nawk -F',' -v OFS=':' -f emp.awk conf.csv input.csv emp.awk: Code:
NR==FNR { a[$1] = $2; next }
$1 in a { $1=$1 OFS a[$1]; print}
|
|
#3
|
|||
|
|||
|
awk
Hi,
input: Code:
a: leo pf1 leave1 basic1 hra1 james pf2 leave2 basic2 hra2 tony pf3 leave3 basic3 hra3 b: leo 210375 james 210075 tony 210378 Code:
leo 210375 pf1 leave1 basic1 hra1 james 210075 pf2 leave2 basic2 hra2 tony 210378 pf3 leave3 basic3 hra3 Code:
awk '
{
if (NF==2)
id[$1]=$2
else
print $1,id[$1],$2,$3,$4,$5
}' b a
|
|
#4
|
|||
|
|||
|
Thanks for your replies ....
I'm unaware of awk programming .... can you please explain me the logic used here ?? Many Thanks |
|||
| Google The UNIX and Linux Forums |