Tech and travel

Posts

A spreadsheet with Python functions

2008-01-23

Resolver is a spreadsheet, running on .Net, in which you can write functions in Python. An example is : for row in workbook["Sheet1"].Rows: if (row["Gross Price"] > 25 and row is not workbook["Sheet1"].HeaderRow): row.BackColor = Color.PeachPuff This is run after a change is made to the spreadsheet. The code loops over all the rows in the first worksheet. If the “Gross Price” column is bigger than 25 and the row is not part of the header row, then the background colour of the row is set to PeachPuff.

Countries visited

2008-01-08

Beginning of the year, not much to do at work. So I’m planning my holidays. There are still some new places to visit : The ones in red are the visited ones. Update : a page called Countries visited was added to site.

Using twill to check my lotto numbers

2007-12-06

Twill is, according to their website, a simple scripting language for Web browsing. It’s a language in it’s own right, but all the command can be called from within Python. Here’s an example : from twill.commands import * my_numbers=[ [2, 4, 6, 8, 10, 12], [8, 10, 12, 14, 16, 18], ] config("use_tidy", "0") redirect_output("log.txt") go('http://www.national-lottery.co.uk/player/p/results/results.do') for row, l in enumerate(my_numbers): for i, value in enumerate(l): fv("quickCheckerForm", "longPlayslipForms[0].drawGameBoards[%i].numbersChosen[%i]" % (row,i), "%i" % value) fv("quickCheckerForm", "drawSubTypeID", "1") submit() try: find("Congratulations") print "Won something !

Kew

2007-11-05

On a lovely autumn day, I went to see the Henry Moore statues at Kew gardens.

Tree

Tree

Using pyparsing – 2

2007-11-02

Parsing sql statements like the following is dead simple with PyParsing. INSERT INTO table_a VALUES ('A', 'B', 'C'); INSERT INTO table_a VALUES ('D', 'E', 'F'); This is the program : from pyparsing import Suppress, delimitedList, sglQuotedString, removeQuotes sglQuotedString.setParseAction( removeQuotes ) stmt = Suppress("INSERT INTO table_a VALUES (") + delimitedList(sglQuotedString) \ + Suppress(");") f = open('some_file.sql') lines=f.read() for tokens, start,end in stmt.scanString(lines): print tokens f.close() PyParsing already knows about quoted strings. The sglQuotedString type matches a single quoted string, which is handy for strings in SQL.

Copyright (c) 2025 Michel Hollands