For Programmers: Free Programming Magazines  


Home > Archive > AWK > January 2005 > Re: grabbing data from columns









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: grabbing data from columns
William James

2005-01-20, 3:56 pm


rudz wrote:
> thanks for you efforts, will i had trouble executing ur script, gave

me an
> error,



What error?

Run the program this way:

awk -f bigreport.awk data.txt


This version removes carriage returns:

{ gsub( /\r/, "" ) }
{
MPrice = substr($0,78,9)
if ( MPrice !~ /1\.000 [A-Z][A-Z][A-Z]/ )
next
$0 = substr($0,1,77)
BVal = $NF
print BVal,MPrice
}

Using awk, mawk, or gawk, the output is:

(6,825.51) 1.000 AUD
8,363.79 1.000 CAD
(138.52) 1.000 CAD
45,454.08 1.000 GBP
68,533.42 1.000 GBP
(12,675.93) 1.000 GBP
(34,570.71) 1.000 GBP
(45,381.67) 1.000 JPY
397.62 1.000 JPY
238,099.67 1.000 JPY
(3,076.40) 1.000 JPY
297,446.56 1.000 USD
(27,860.68) 1.000 USD
41,853.98 1.000 USD

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com