In order to program his pick-and-place machines, our prototyping supplier for the development boards on The Public Radio requested a document (CSV or spreadsheet) with part names and X/Y coordinates. We figured that EAGLE could probably do this easily, but the process ended up being a bit tricky.
EAGLE, in all it's weirdness, generates plain-text partlists that are formatted by column (i.e. each field starts on a given character column in the file). Ours starts out like this:
There are a few problems with this. First, a bunch of it is superfluous; we already have a partlist (which we created in Google Docs and links directly to manufacturer product numbers). Second, some of the "Value" fields are missing, making it difficult to index a given word on a line. Third, there are inconsistent delimiters; at first I thought I could use spaces, but the missing values screwed that up (and the manual solution was, for a few reasons, unappealing to me).
So the problem: How to process this to produce a document with consistent, useful formatting and no superfluous information?
The answer: A shell script.
My end result is hosted on Github, here. It's the first shell script I've written in probably ten years, but AFAICT it works well.
The function takes one argument from stdin, which should be the plain-text partlist exported directly from EAGLE. It creates a second document for output and then processes the input file, sending just the necessary information to the output - and separating all fields with a comma in the process. The output looks like this:
I'm pretty crappy at scripting these days, so it took me a few hours to complete - but the end result is exactly what I wanted, and we used it numerous times in the few days since I wrote it.
In short: This was arguably the biggest success of my whole week. And it was fun to write, too! Check it out if you're interested :)