09 November 2012

Geek: Dealing With .vnt Files

I switched this year from an iPhone to an Android phone, for a few reasons, which I might get into at some point in the future.  I use the Memo app on 'Droid to record notes; very often I use it to keep track of my weight before a hike, as well as the weight of my gear.  Getting data out of the app proved to be annoying.  I can export it to my computer through Dropbox, but it's in a .vnt format, that looks an awful lot like a vCard format, but I couldn't find any pre-built software capable of parsing it.  I was, however, able to come up with a quick workaround.

N.B.: this post assumes that you have a basic working knowledge of Linux, FreeBSD, or some other Unix or Unix-like system.  It assumes that you can install packages (vpim) on your system, and it also assumes that you know HOW to install packages (or compile software from distributed source code).  It also assumes that you have already have exported the Memo that you wrote on your Android phone into a .vnt format file.  It assumes that you are staring at that file, debating whether or not to just do a search and replace on those =0D=0A characters, and wondering why the Memo app couldn't just export a text file.

The .vnt file looks like this:
[doug@airship-pirate work]$ cat 2012-11-
[doug@airship-pirate work]$ 
So, the content is in there, "Test Message Here", but it's a bit hard to work with.  You have a few options for translating this.  The most robust way is to use a vNote reader, but I have yet to find one, or have reason to write one.  So we'll use a vCard reader instead.  The package "vpim" provides a few utilities, including vcf-dump, which we'll exploit for our own nefarious purposes in just a moment.  First, though, we have to tweak that VNOTE into a VCARD.  If you don't do this step, vcf-dump gets all cranky.
[doug@airship-pirate work]$ sed -e 's/VNOTE/VCARD/' 2012-11- > 2012-11-
[doug@airship-pirate work]$ head -1 2012-11-
[doug@airship-pirate work]$ 
Easy enough.

Next, run it through vcf-dump:
[doug@airship-pirate work]$ vcf-dump 2012-11-
Great.  vcf-dump handled translating that quoted-printable string, and presumably would handle other encodings as well (i.e. base64), without too much effort on our part.

Finally, the last step.  I'm going to grab that "Body" line, cut out the portion between the quotes, and then translate those CRLFs ("\r\n") into actual newlines. 
[doug@airship-pirate work]$ vcf-dump 2012-11- | fgrep "Body=" | cut -f 2 -d '"' | sed -e 's/\\r\\n/\n/g'


I hope that helps.  Please remember to back up any files prior to attempting to translate them, since one botched '>' can ruin your day.

No comments:

Post a Comment