[Haskell-beginners] Help with CSV

Hong Yang hyangfji at gmail.com
Wed Sep 2 18:40:38 EDT 2009


I need to process csv files that have the characteristics as follows:
1)    each file has thousands of columns which have String, Int, and Double
types
2)    the number of columns may change
3)    for those columns whose name do not change, their location may change

I want to process some columns in 3) using Haskell.

In Perl, I can easily have the code like below:

use Text::CSV;
my $csv = Text::CSV->new( { allow_whitespace => 1 } );
open my $temp, "<", "temp.csv" or die "Cannot open temp.csv! ($!)";
my @fields = @{ $csv->getline($temp) };
$csv->column_names(@fields);
while ( my $hr = $csv->getline_hr($temp) ) {
    my $sn = $hr->{"UNIT:unitSerialNumber"};
    # processing goes here ...
}
close $temp;

Can someone please give me an equivalent code in Haskell? Then I can digest
and expand it.

Thanks,

Hong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090902/0efd9ff1/attachment.html


More information about the Beginners mailing list