from __future__ import *
Talking Panda Update
May 23, 2005 at 11:37 PM | categories: java, python, iPod, macosx, py2app, perl, PyObjC, pil, General | View CommentsWe've (finally) updated talkingpanda.com today with a fresh new look and a new product: iBar.
iBar turns your iPod (any iPod with a screen and a dock connector) into an "ultimate bartending tool" with over a thousand drink recipes, mixing techniques, and even a couple history lessons. Like any good bar should be, it's stocked. Altogether, the Notes content adds up to over 3 megabytes (yes, that's text!) with more than 40 minutes of original, professionally recorded, audio.
Like its sibling iLingo, iBar ships with installers for Mac OS X and Windows XP/2000 (everywhere iTunes is supported) that make installation painless.
And for relevance, here's a little bit about how it's all put together:
- The Mac OS X installer was developed with Python 2.3, PyObjC 1.2, and bundled up with py2app.
- The Win32 installer was developed with Python 2.4, win32all, Tkinter, PIL and is bundled up with py2exe and then made self-contained with NSIS.
- The build scripts for the installer application actually use even more open source stuff. We use JExcelAPI to convert Excel spreadsheets to XML, and Win32::Exe to swap out the ICO resource out of win32 executables -- but no Java or Perl makes it into the redistributable :)
We're also blogging updates and podcasting some of our content, so point your NetNewsWire or Safari RSS over to Talking Panda News!
Forget Spreadsheet::ParseExcel!
August 24, 2004 at 10:32 PM | categories: python, java, perl | View CommentsI've been working on some automation scripts to take data out of excel and do useful things with it, and I hit a big stumbling block with Spreadsheet::ParseExcel. Unicode SUCKS in Perl, and Spreadsheet::ParseExcel does nothing at all to help you with that. Each cell gets its own encoding ('ucs2', '_native_' which I haven't seen, or it's simply undef.. which seems to be latin-1). Anyway, it's completely bogus, so I started shopping around for another implementation.
Andy Khan's JExcelApi does the trick and is light-years more correct and faster than the alternatives I have tried (other than the time it takes a JVM to start). Not only that, but by default the jar does exactly what I want it to do. It gets the unicode right, and everything worked perfectly the first time. My dealings with Excel files have been reduced to the following:
java -jar -Djxl.encoding=latin1 jxl.jar -xml EXCELFILE.xls
And the Python code to parse the workbook xml document from jxl looks roughly like this:
from xml.dom import minidom
def parseDocRows(doc):
for row in doc.getElementsByTagName(u'row'):
rowdata = [
u''.join([x.nodeValue for x in col.childNodes])
for col in row.getElementsByTagName(u'col')]
if rowdata:
yield rowdata
if __name__ == '__main__':
import sys
for row in parseDocRows(minidom.parse(file(sys.argv[1]))):
print row
Thanks!