February 21, 2014 at 11:29 PM by Dr. Drang
I’m starting a long series of tests at work involving many different parts exposed to a variety of chemicals. Devising the test setup was interesting, and I expect analyzing the results to be interesting, too. But this middle section—actually doing the tests—is going to be pretty boring. Lots of bookkeeping, not much thinking. This is the stage that’s easy to screw up because it seems too easy to screw up. Organization is key.
Altogether, I have almost 150 part/chemical combinations to keep track of simultaneously. Some of the parts are easy to distinguish visually, but many aren’t; none of the chemicals are visually distinct. The parts themselves can’t be labeled because that might interfere with the chemical treatment. Because the treatment will take place in small glass jars, the best way to keep track of the tests is, pretty obviously, to label each jar with the part and chemical.
How to do the labeling? Labs that perform the same kinds of tests in large batches over and over have standard procedures for running standard tests on standard samples, and have standard lab management software that produces standard labels. I don’t have that kind of lab or that kind of software, but I do have a label printing script that’s flexible enough to handle most of what I run into. I just need to create the proper input file.
Let me stop here for a bit and say that writing the information by hand on the lid of each jar is certainly an option, and that’s what I’ve done for smaller scale tests. But writing on 150 jars is not only horrifically dull, it’s error-prone. The same is true of using a template; time can be saved by copying and pasting, but it’s easy to paste in the wrong spot. The time-saving aspects of automation are what people usually talk about, but its accuracy is just as important.
I had a list of all the parts, one part per line. What I needed was to convert that list into the input format needed for my
ptlabels (“print tiny labels”) program. That meant transforming something like this:
0001 0002 0003 0004
into something like this:
#0001|Temperature X Chemical A Chemical B Chemical C Chemical D #0002|Temperature X Chemical A Chemical B Chemical C Chemical D #0003|Temperature Y Chemical A Chemical B Chemical C Chemical D #0004|Temperature X Chemical A Chemical B Chemical C Chemical D
Did I mention that the tests were going to be carried out at different temperatures? That’s another bit if information that has to be on the label.
There are many ways to do this sort of transformation, but because I’m using BBEdit, its command came to mind. The first transformation was this,
which added the temperature information and the hash and vertical bar formatting symbols. I then went through the list and changed
Temperature X to
Temperature Y where appropriate—about a half-dozen places. As there was no relationship between part number and testing temperature, brute force was the fastest approach.
The next step was to add a suffix only.
You can’t see everything in the little text field, but you can probably guess that the suffix is
&Chemical A&&Chemical B&&Chemical C&&Chemical D&
Why didn’t I have this as part of the suffix in the previous step? Because that would have made changing those half-dozen
Ys more difficult because they’d be buried in the middle of their lines.
The last step is a regular expression (grep) find/replace that turns all the ampersands into newlines.
There are probably better ways to transform the text, but these are the steps I thought of first. Trying to think of a better solution would’ve just wasted time.
I saved the transformed file and passed it to
ptlist, which printed out all the labels on a couple of sheets of Avery 5167 paper. Avery 5167 is meant to be used for return addresses but I’ve used it label several types of lab sample.
The jars come from the supplier in boxes of 24. An unplanned benefit of using stickers instead of hand-printing the information was that I could label all the jars without removing them from the boxes.
This kept my limited bench space tidier. It also kept the jars in order, which will speed the adding of parts and chemicals in the next stage.
This post, there’s nothing bright about it, and there’s probably nothing in it that anyone else can use directly. But by leveraging previous work and using the built-in features of my text editor,1 I was able to save myself at least an hour of work, and I ended up with something that was neater and better organized than I would have had otherwise.
Those of you with access to multiple cursor editing are probably thinking of a faster way to transform the parts list. ↩