in reply to Re^3: Why is the following instance of Matching using an array element not working
in thread Why is the following instance of Matching using an array element not working
I have worked with Text::CSV in the past. I have only slight issue with it, which I am not sure if I am not getting how to use it correctly. Here is the following code:
my $csv = Text::CSV->new(); open (CSV,"<", "Merged_CSVfiles.csv") || die "File not found\n"; while (<CSV>) { # While Loop Open Bracket next if ($. == 1); if ($csv->parse($_)) { #If Open Bracket my @columns = $csv->fields(); #__ Assigning $columns[0]-$columns[26] to variables my @Sample_Ids_m = $columns[16]; print ($Sample_Ids_m[0]); } else { # If Closed Bracket # Else Open Bracket my $err = $csv-> error_input; print "Failed to parse line: $err"; close CSV; } # Closed Else Bracket }#Closed While Loop Bracket
All the ID are loaded into the first element of the array @Sample_Ids_m. This would be a problem but arrays can be different lengths and there are no rules current for constructing Sample ID numbers. It is a random sort of thing.
If there was some uniformity I could use the substr function and a for loop and extract our individual id's but I dont seem to be able too. I will play around with it for a bit more
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Why is the following instance of Matching using an array element not working
by Kenosis (Priest) on Aug 11, 2012 at 05:53 UTC | |
by MyJeweledPerls (Initiate) on Aug 13, 2012 at 21:22 UTC | |
by Kenosis (Priest) on Aug 13, 2012 at 21:29 UTC |