Search the web
Sign In
New User? Sign Up
perl-beginner · Perl Beginners Mailing List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Looping through an array by element   Message List  
Reply | Forward Message #26196 of 26720 |
The goal is to find out if any columns in a CSV have no data. The
number of columns will be unknown.

Here's how I'm getting the file into an array @recs.

$mil="c:/production/work/tool.txt";
open MIL, $mil or die "Cannot open input file for read :$!";

while (<MIL>)
{
$_=substr($_,0,200);
@recs=split /,/,$_;
}

Example CSV file with elements[1],elements[2],elements[3] without data:

$AT0000634076-VIE,,,,$RDU-VIE
$AT0000726435-VIE,,,,$HTE-VIE
$AT0000726443-VIE,,,,$CTE-VIE
$AT0000726450-VIE,,,,$PTE-VIE
$AT0000726476-VIE,,,,$CXE-VIE
$AT0000802079-VIE,,,,$RDX-VIE


I can't figure out how to loop through the array and sum the columns.

If I can loop through, I'll use this: $l=$l+length($recs[$i]); and if
it has a zero value, then that column has no values.

I've tried foreach but that seems to make an element out of a record.

Any help appreciated.

Don





Fri May 9, 2008 9:29 pm

dachner2002
Offline Offline
Send Email Send Email

Forward
Message #26196 of 26720 |
Expand Messages Author Sort by Date

The goal is to find out if any columns in a CSV have no data. The number of columns will be unknown. Here's how I'm getting the file into an array @recs. ...
dachner2002
Offline Send Email
May 9, 2008
9:29 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help