in reply to parsing with Workflow::csv_File

There is no module Workflow::csv_File on CPAN.

Maybe it would help us to help you better if you would post five (relevant) lines from each table, together with an explanation of how they belong together and what they indicate. Also, please show us the relevant parts of the code you already have written and how it fails to do what you need it to do.

Replies are listed 'Best First'.
Re^2: parsing with Workflow::csv_File
by devoted_to_Perl (Initiate) on Nov 28, 2011 at 12:48 UTC

    Sorry, that package reads from a specified filename and the subroutine is as following:

    sub read_file { my $self = shift; my $filename = shift; my $i = 0; my $header_parse = 0; my $header_name = 0; open FILE, "<$filename" or die "cannot open $filename for input\n"; while (my $line = readline (*FILE)) { # Strip newlines and leading / trailing whitespace for ($line) { chomp; s/^\s+//; s/\s+$//; } # Skip blank lines and comments next if ($line !~ m/\w/ || $line =~ m/^#/); if ($line =~ m/^\[\s*([\w|\s]+)\s*\]/) { $header_name = $1; $header_parse = 1; } elsif ($header_parse) { $self->{HEADERS}{$header_name} = $line; $header_parse = 0; } else { my @data = split $self->{REGEX}, $line; $self->{DATA}[$i++] = \@data; } } close FILE; }

    The first matrix/table in a .csv file I need to read/loop from is as following:

    POSITION R CH TW TH

    1 2 2.0 60 100

    2 4 2.5 61 100

    3 6 2.8 62 88

    .. .. .. .. ..

    N 40 0.9 74 18

    while the structure of one of the J tables linked to the first table through the TH array is as following:

    Header 100 (or a value from 88 .. to 18, referring to TH in the first table)

    A B

    -180 0.1

    .. ..

    M 0.9

    I don't know how to parse the header (in the first table) in one of the J tables with the corresponding header.