use DBI; ... #MS Windows path to files my $fpath="G:\\in"; #LINUX server paths #my $fpath="/users/excel/in"; my $csvfile="Trx_24Aug2012_0409.csv"; my $cellh = DBI->connect("DBI:CSV:f_dir=$fpath;csv_eol=\n;"); #associate csv file with tablename my $fname=$fpath.'/'.$csvfile; $cellh->{'csv_tables'}->{'CELLS'} = {'file' =>$fname}; my $sql="select * from CELLS"; my $stcellh = $cellh->prepare($sql) or die "$DBI::errstr\n"; $stcellh->execute() or die "$DBI::errstr\n"; my $colunmcount = $stcellh->{NUM_OF_FIELDS}; print "$colunmcount\n\n"; $stcellh->finish();