sud
asked on
Reading Excel File
Hi Experts,
I want to read .CSV file using PERL, the file has three columns, list1, list2 and list 3. I want to read values of the three columns.
Can you please help me how i can do this ?
Thanks
SS
I want to read .CSV file using PERL, the file has three columns, list1, list2 and list 3. I want to read values of the three columns.
Can you please help me how i can do this ?
Thanks
SS
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Experts,
my first row is a column name, so how to take care of that?
thanks,
sudhir
my first row is a column name, so how to take care of that?
thanks,
sudhir
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Experts,
I am able to read .CSV file,
Now I am trying to compare value of first column from .csv file to file name in the directory(A:/temp/RAW), if it matches then print the filename.
Can you please help me how to do it.
here is my code
use strict;
use warnings;
use File::Find;
open CSV, "A:/temp/test.csv" or die "Can not open file.csv $!\n";
my @columnnames=split(/,/,<CS V>);
while (<CSV>) {
chomp;
my ($list1, $list2, $list3) = split /,/;
find (\&matchPattern, 'A:/temp/Raw');
sub matchPattern
{
if ($File::Find::name =~ '.txt' ) {
if ($File::Find::name = "$list1"){
print "$list1";
}
}
}
}
I would appreciate ur help or suggestion. Thanks,
I am able to read .CSV file,
Now I am trying to compare value of first column from .csv file to file name in the directory(A:/temp/RAW), if it matches then print the filename.
Can you please help me how to do it.
here is my code
use strict;
use warnings;
use File::Find;
open CSV, "A:/temp/test.csv" or die "Can not open file.csv $!\n";
my @columnnames=split(/,/,<CS
while (<CSV>) {
chomp;
my ($list1, $list2, $list3) = split /,/;
find (\&matchPattern, 'A:/temp/Raw');
sub matchPattern
{
if ($File::Find::name =~ '.txt' ) {
if ($File::Find::name = "$list1"){
print "$list1";
}
}
}
}
I would appreciate ur help or suggestion. Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Ozo,
Somehow ur program does not give any output.
My following program gives me correct output except that it prints result twice , any suggestion ?
use strict;
use warnings;
use File::Find;
find (\&matchPattern, ''A:/temp/Raw'');
sub matchPattern
{
if ($File::Find::name =~ '.xpt'){
open CSV, "A:/temp/test.csv" or die "Can not open file.csv $!\n";
my @columnnames=split(/,/,<CS V>);
while (<CSV>) {
chomp;
my ($list1, $list2, $list3) = split /,/;
if ($File::Find::name = "$list1"){
print "$list1";
}
}
}
}
Somehow ur program does not give any output.
My following program gives me correct output except that it prints result twice , any suggestion ?
use strict;
use warnings;
use File::Find;
find (\&matchPattern, ''A:/temp/Raw'');
sub matchPattern
{
if ($File::Find::name =~ '.xpt'){
open CSV, "A:/temp/test.csv" or die "Can not open file.csv $!\n";
my @columnnames=split(/,/,<CS
while (<CSV>) {
chomp;
my ($list1, $list2, $list3) = split /,/;
if ($File::Find::name = "$list1"){
print "$list1";
}
}
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
my($list1,$list2,$list3) = spit/,/;