Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting data from columns in a textfile with headers...

Status
Not open for further replies.

jmg498

Technical User
Oct 31, 2007
26
US
I have a text file in the following format:

HEADER1
HEADER2
COL1 COL2 COL3 COL4 COL5

With data in each column. What I'd like to do is extract, for example, all data in COL2 and COL4...and write those columns to another file. I also need to ignore the headers that appear before the data columns.

Is there a simple way to do this in Perl? Writing to a file is pretty easy, so really I just need a way to store the data in the columns I want into arrays.

Thanks for any and all help!
 
I should mention that I have the contents of the files stored in arrays. I just want to extract an entire column from each of the arrays.
 
Yes

What have you tried so far? Post some code and we'll have a look at it...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
shift @array;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top