C
ccc31807
I have a csv file with 10K items. The header looks something like this:
CustNo,Name,FirstPaidItem,FirstOrderedItem,FirstShippedItem,Items
The first five fields are single valued. The last field (Items) has many items. Lines may look like this:
1,Joe,a,a,a,a,b,c,d,e,f,g,h,i
2,Jane,a,a,b,a,,,,,,a,b,c,d,e
3,Jim,b,a,a,a,b,c,d,e,f,g,h,i
4,Jill,b,b,b,b,,,,,c,,b,,e,f,g,h
I parse the file like this, putting the first five values in scalars and the remainder in the @items array:
foreach line
my ($custno,$name,$paid,$ordered,$shipped,@items) = split on the commas
The objective is to take the first item in the @items array and match it toone (or more) of $paid, $ordered, or $shipped. I just want to grab the first item in the @items array that has a value, IOW, skip all the blank items(as in line 2 above) that precede the first actual value.
Is there a quick and dirty way to do this without having to do this>
my $item = '';
foreach my $ele (@items)
{
$item = $ele if $ele =~ /\w/;
last;
}
Thanks, CC.
CustNo,Name,FirstPaidItem,FirstOrderedItem,FirstShippedItem,Items
The first five fields are single valued. The last field (Items) has many items. Lines may look like this:
1,Joe,a,a,a,a,b,c,d,e,f,g,h,i
2,Jane,a,a,b,a,,,,,,a,b,c,d,e
3,Jim,b,a,a,a,b,c,d,e,f,g,h,i
4,Jill,b,b,b,b,,,,,c,,b,,e,f,g,h
I parse the file like this, putting the first five values in scalars and the remainder in the @items array:
foreach line
my ($custno,$name,$paid,$ordered,$shipped,@items) = split on the commas
The objective is to take the first item in the @items array and match it toone (or more) of $paid, $ordered, or $shipped. I just want to grab the first item in the @items array that has a value, IOW, skip all the blank items(as in line 2 above) that precede the first actual value.
Is there a quick and dirty way to do this without having to do this>
my $item = '';
foreach my $ele (@items)
{
$item = $ele if $ele =~ /\w/;
last;
}
Thanks, CC.