So after a nearly 4 month hiatus from even bothering to look at my coding, I sat down and cleaned up the parsing code I wrote way back when and got some subroutines going for it. Nothing too fancy, but it should discriminate satisfactorily between RIS and BiBTex formatted library exports (based upon file extension). I’ll probably throw in a screener to check the first line or two of the input file just to be on the safe side, but running on extension alone for now should be fine. Click on through for the code!
As I’ve already got the parser and uploader mashed together1, this piece won’t be hard to integrate in. Now it’s just time to write another subroutine or two for the other more common citation library formats, and this script will be ready to rock2!
Added perk: I totally just got my <pre> tags to wrap properly within my frames! Woohoo!
<perma-embed in CSS-file />
1I haven’t put that code up yet, as I got distracted by life in the interim. But, it’s totally functional. Fo’realz!
2Well, on Mac OS X and/or Unix systems at least. I need to verify and/or troubleshoot the script on Windows-based platforms, as I’m unsure how good the
File::Spec are at respecting the different operating systems.
I wrote a script in Perl to take a RIS-formatted citation library and parse it into a JSON file compatible for use with CiteULike‘s API. It’s a bit sloppy, but considering I’ve had their API since October, it’s about fucking time I did it.
It’d be relatively trivial to tweak this to parse out a Papers library XML export, or change it around to probably work its magic on a BiBTex-formatted citation. I’ll slowly work on getting something up and running to tweak around between formats and auto-parsing them. But first, I need to get this mish-mashed all into one script to do it all; none of this leaving a password around in a flat-file text document. Bleargh! Unfortunately, at the present time it’s just optimized for Mac systems (for defining the file path). I’ll also tweak that as I go and see if I can get it to work okay in the Windows environment (going to make me feel dirty though).
Granted, this took me most of the evening, but I’m quite proud of myself so far. I already used it to parse and upload my entire Papers library to finally merge that with my CiteULike library. Click on through below to get at the code. And note to self: find better way to implement code into my WP blog.