How to read a two columns file (178 Views)
Reply
Occasional Advisor
SwissKnife
Posts: 8
Registered: ‎10-21-2011
Message 1 of 4 (178 Views)
Accepted Solution

How to read a two columns file

Hi,

 

I need something like that:

Read a file having 2 columns and provide a specific compute on each column.

 

If I schematize the idea it could be like this.

 

For each line of the text file

 -> call a function with value in column one

 -> doing something else with the column two

....

 

Thanks in advance,

Den.

Please use plain text.
Honored Contributor
Steven Schweda
Posts: 9,036
Registered: ‎02-23-2005
Message 2 of 4 (156 Views)

Re: How to read a two columns file

Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,389
Registered: ‎03-06-2006
Message 3 of 4 (151 Views)

Re: How to read a two columns file

[ Edited ]

Besides Steven's "while read", you can use awk's fields, $1 & $2.  Of course you could need to write your function in awk, possibly using system to invoke a script.

Please use plain text.
Occasional Advisor
SwissKnife
Posts: 8
Registered: ‎10-21-2011
Message 4 of 4 (129 Views)

Re: How to read a two columns file

Thank you!

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation