« Help! | Main | Lost in the supermarket »

How do you? — redux

21 September, 2007

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".

Comments

If you have the command "hexdump" (Linux does, I assume MacOSX does too), it will show you hidden characters in text files:

hexdump -c myfile | less

I have no idea what you're rattling on about. It all seems rather complicated.

*goes off and types some gibberish in hexadecimal

10 read post
20 get confused
30 get headache
40 give up
50 goto pub

geddit? hah very BASIC humour

Post a comment

Enter the code shown below before pressing post

About the Rat

Black Knight is interested in the interaction of science (as a day job and as a way of thinking) with his family, the wider community and literature. And tormenting students. Frequently polemical, sometimes serious, and hopefully always entertaining more

blackasknight@gmail.com

Recent Comments

Life

All your base are belong to us The BioLOG is back, bigger and bad to the bone

LabLit From the blurb: LabLit.com is dedicated to real laboratory culture and to the portrayal and perceptions of that culture – science, scientists and labs – in fiction, the media and across popular cultur

Mind the Gap Adventures in the London sci-lit-art scene...and occasionally beyond

Humans in Science Similar to 'Lab Rats', a very human look at the process of doing science and how daily life impacts our profession

Media

The Daily Grind Jonathan Sanderson, a TV producer interested in making 'popular science' shows

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.2