Talk About Network

Google


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 > Re: Process two...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 10 Topic 2151 of 2317
Post > Topic >>

Re: Process two files simultaneously

by Combatwombat <combatwombat@[EMAIL PROTECTED] > Feb 8, 2008 at 03:46 AM

Ed Morton wrote:
> 
> On 2/7/2008 1:45 AM, Combatwombat wrote:
>> Thanks for your reply, Ed!
> 
> You're welcome, but in future please leave enough context so your post
stands
> alone as this is netnews not a web forum.
> 
>> The old.csv has numerous lines like this:
>>
>> AAA80008	Automobile fins		AAA	CS	0
>>
>>
>> the replacement csv has lines like this:
>> AAA 	Archies Automobiles and Airplanes
>>
>>
>> so by replacing the AAA in the record of old.csv we end up with:
>>
>>
>> AAA80008	Automobile fins		Archies Automobiles and Airplanes	CS	0
>>
>> Thanks!
> 
> If those are tabs between the fields then all you need is:
> 
> awk 'BEGIN{FS=OFS="\t"} NR==FNR{a[$1]=$2;next} {$3=a[$3];print}'
replacement.csv
> old.csv
> 
> 	Ed.
> 

Thanks, Mate! that did it;
awk 'BEGIN{FS=OFS=":"} NR==FNR{a[$1]=$2;next} {$4=a[$4];print}' 
replacement.csv old.csv > result.csv

(there was another tab in there, and the csv is colon delimited)
You the man, I've spent hours ba****ng my head on this one, and was just 
about to go and learn python to do it.
 




 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 Thu Jul 24 0:49:59 CDT 2008.