Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Process two fil...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 2151 of 2236
Post > Topic >>

Process two files simultaneously

by Combatwombat <combatwombat@[EMAIL PROTECTED] > Feb 7, 2008 at 03:35 PM

##ALERT!!!### Noobie struggling with Awk

Hi all,

I have a problem trying to figure out how Awk can process two input 
files simultaneously, as there is some reference on the web to it doing 
so, eg http://www.vectorsite.net/tsawk_3.html,
but it is short on detail 
and example. I am running Ubuntu 7.04 (gawk I think).

Problem: take one csv file full of data, including one field that needs 
to be changed/processed on a regular, automatic, scalable basis. Take 
second csv file with data in two columns; first column = field matching 
data in first csv, second column = field of replacement data.

So far I have:

in Batch file:

cat old.csv replacement.csv | awk -f awkins f1="old.csv" 
f2="replacement.csv" >> newfile

awkins file:

BEGIN  { FS = ":" };{

if($10 =="y"||$10=="Y"){ # begin process of extraction because ALLOWSELL=y
qty=$6+$8;
if (($37 =="N"||$37=="n")&&qty<=0){
	status=9
}else{ status=1;
}
{

print $1,"	",$1".jpg","	",$1,"	",$2,"	","url","	",$7,"	",$7,"	",qty," 
",$4,"	",$5,"	",status,"EOREOR";

}
}
}

I couldn't fihure out how to get Awk to look at the second file; getline 
  worked with it , but filled the field variables with data from the 
second file.
Thanks for any hints or help!




 10 Posts in Topic:
Process two files simultaneously
Combatwombat <combatwo  2008-02-07 15:35:34 
Re: Process two files simultaneously
Ed Morton <morton@[EMA  2008-02-07 00:45:51 
Re: Process two files simultaneously
Combatwombat <combatwo  2008-02-07 20:45:48 
Re: Process two files simultaneously
Ed Morton <morton@[EMA  2008-02-07 08:01:22 
Re: Process two files simultaneously
Combatwombat <combatwo  2008-02-08 03:46:46 
Re: Process two files simultaneously
Janis Papanagnou <Jani  2008-02-07 19:35:34 
Re: Process two files simultaneously
Combatwombat <combatwo  2008-02-08 09:53:59 
Re: Process two files simultaneously
Ed Morton <morton@[EMA  2008-02-07 14:59:43 
Re: Process two files simultaneously
"Luuk" <luuk  2008-02-07 10:27:08 
Re: Process two files simultaneously
Janis <janis_papanagno  2008-02-07 04:44:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 13:04:31 CDT 2008.