Wednesday's post was born of frustration. You see, I had a nice script hacked together, but it just would not 'print' what I expected it to during my debugging. Which made me think I was doing something boneheaded. I implemented Paul's suggestion, and I was still not getting the expected output.
Then it struck me. If my code was good, the CSV itself (produced by Filemaker) must be knackered. And indeed, playing with CSV::text showed that perl was barfing on, and thus unable to parse, the very first line.
I left the problem alone yesterday, mainly because we had a group meeting with a visiting speaker and I had to put together a spiel for it, but also because it felt like my brain was oozing out of my ears.
So this morning, I went to talk to my cells, came back to my desk, sipped the coffee that the Black Queen had kindly bought for me, and constructed a very simple CSV file;
"r1c1","r1c2","r1c3","r1c4"
"r2c1","r2c2","r2c3","r2c4"
Then I showed it to my perl script (irrelevant bits stripped; yes I'm using 'strict'):
open (CSV, $probefile) || die "Can't open probefile! $!\n";
while (<CSV>) {
chomp;
($probeSetID, $chr, $start, $stop) = split (/,/,$_);
push (@probeSetIDs, $probeSetID);
push (@chrs, $chr);
push (@starts, $start);
push (@stops, $stop);
}
close CSV;
print join("\t", @probeSetIDs), "\n";
print join("\t", @chrs), "\n";
print join("\t", @starts), "\n";
print join("\t", @stops), "\n";
And BINGO! Four arrays, each with the appropriate column:
"r1c1" "r2c1"
"r1c2" "r2c2"
"r1c3" "r2c3"
"r1c4" "r2c4"
The conclusion is that Filemaker Pro can't make proper CSV files. There appears to be an invisible character in the first line. Oh hum. There are ways around this, I hope, but damn, it'd be nice to be able to trust something occasionally.
As they say,
"AHS, ASS".