Simbiosis

Communiques from the wilderness

HTML table parser using Python

More on the python front. This is my first cut at extracting HTML tables from webpages, and returning them in arrays, using Python. (Files here) The usage would look something like this:

import urllib
from table_parser import *

f = urllib.urlopen('http://myweb.com/data.html')
p = TableParser()
p.feed(f.read())
f.close()
print p.doc # Get to the data

May 17, 2006 Posted by Nigel | python | | 9 Comments

Date sweep

On more than one occasion I've needed to iterate over all dates between two dates, and although the code and concept are trivial it does normally take up 20 minutes to find the exact classes to use, simply because it is a long time between uses. So here's the snippet, more for my own reference, but it will probably be useful to others too.

from datetime import date, timedelta
step = timedelta(1) # one day at a time
start = date(2005,1,1)
end = date.today()
d = start
while d <= end:
print d
d = d + step

May 17, 2006 Posted by Nigel | python | | No Comments Yet

IP Webcam (ip2031)

Another eBay purchase. An embedded ethernet USB webcam server (IP2031).

It seems like a neat enough unit, running off 5volts. It comes built in with motion detection software, which can upload to an FTP site on change. This seems to operate OK, except for a couple of empty images. Even so, I would like to be able to grab straight to disc, and use motion to do the motion detection.
You can grab individual frames by hitting a http url, but this seems to freeze up after a couple of frames, or at least at a rate >  1fps. They do provide a Java live webcam viewer which achieves 10fps (and uses 100% CPU). After quite a bit of packet sniffing I’ve managed to put together a python class (parent) to grab images from the UDP stream, which doesn’t appear to freeze up (as much).

May 9, 2006 Posted by Nigel | python, technology | | 2 Comments

My new home

Well, this may not be my only corner of cyberspace, but it is certainly
my newest. This blog, which is basically just a series of notes to
myself, has just been moved from LiveJournal.com. Basically because
LiveJournal didn’t support categories via XMLRPC, so Performancing couldn’t use it, and because LiveJournal didn’t support RSS feeds off indivitual categories.
To make the move I used ljdump to export my records, and then I used this XSLT to convert the records into TypePad format, for importing into WordPress.
xsltproc livejournal-to-typepad.xslt ljdump-1.1/simbiosis/L-* > typepadexport

May 4, 2006 Posted by Nigel | Uncategorized | | No Comments Yet