Reading Unicode CSV Files in Python

The python csv module doesn’t support unicode. That’s a who-cares most days of most years, but if you suddenly have a need to import some csv data that contains letters with little squiggles over them, you’re pretty bummed out.

I’ve had to write csv reading and writing code from scratch before, in Java. CSV may be the most ridiculously terrible file format I’ve ever had the displeasure of being forced to care about, but it’s not very difficult. So I spiked a parser in python that handles unicode.

It’s not complete. It’s probably not even close. I know it doesn’t handle multi-line cells, for one thing. It certainly doesn’t have the bells and whistles that the official module has… but it worked for me. It might work for you too.

If it doesn’t, let me know. I’d be happy to bang on it a bit more to cure what ails it.

Download it here:
http://bitbucket.org/famousactress/dude_csv

Pretty straightforward to play with. Stand up the reader, iterate over the rows. Rows are returned as lists of strings.

f = open('~/myfile.csv', 'rU')
line_reader = DudeUrGettinACSV(f)
for row in line_reader:
    print row

I shot a video.

Helen Earth Band – (We All) Talk With Knives from One Bad Landing on Vimeo.

Trying to revive the blog. I’ve been struggling to keep a hand in creative projects since leaving Sayvinyl. Working with the Helen guys has been awesome. They came to me with the video concept of running split screens and bouncing to tight shots of whoever’s part makes sense to highlight at that point in the song. I dug the idea, because I’ve never really shot video before… The concept is very approachable for someone who thinks like a still photographer. All the shots we’re locked-off. Almost all of them were fixed focus. My job was just to find interesting composition and light. I’m happy with how it came out.

Technicals? We shot it in a practice space that’s probably 9′x12′ or so. Used a black sheet, and a white sheet.. Two wacky daylight-balanced video lights that we stuck in umbrellas or behind gobos in the corners. The white scenes are two lights behind the subject in either corner, blowing out the background.. we used a reflector to light the guys. Dark scenes were usually a single light near the floor left of camera in an umbrella to give an outline, again with a reflector to wrap it around. If you notice the light flickering/shimmering in some scenes… That was us shaking/tickling the reflector. I was really afraid the shots might look sterile, and I thought if I gave a bit of texture and movement to the light, it might feel more like there was really something going on in the room.

Oh, and we shot the whole thing on a 5D Mark 2, and a 50mm 1.2L. Worked out really well for this.

I’m working on another video with the Helen guys now, and I’m really excited about it. It’s a lot more ambitious than the Knives video.. Much more of a short film. We’re a little more than half-way done shooting it, but there’s still a lot to do… it’s getting there, though.

Helen Earth Band

Belly-Up 11/21.

helen

helen

helen

helen

helen

helen

Alive.

I’m still alive, and occasionally still doing things.

Mallory. From last night’s drop-in to share some watermelon beer. Much better than it sounds.

mallory

Moresoonpromise.

Do you play beer-pong like this?

Rediscovering film thanks to the gift of an old Nikon FM from our good friend Bil.

cleary_bday_flm_9
Marc’s cup’s been hit. Whoever hit it, gets to leave Marc a ping-pong shaped welt.

cleary_bday_flm_3
Chris in one of our t-shirts. There’s still a few left. Incidentally, the Mrs. and I are photographing Chris’ wedding this evening. Can’t wait.

This is how you ought to start your day.

Just got up, made coffee, and fell into this slideshow of Glen E. Friedman’s new book. You ought to do the same. It’s a really nice way to start your day.

Then you should order me a copy of the book. My birthday’s in August.

RECOGNIZE photographs by GLEN E. FRIEDMAN (based on images from the Burning Flags Press book) HD.

(You can watch the embed either small or full-screen, but I think your best bet is to hop over to vimeo where you can watch it full screen and in HD.

You’d also do well to add Glen’s blog to your RSS reader. It’s one of my favorite places on the internet right now. He posts some incredible un-published photographs, vegan products, and other well-curated miscellany.

Enjoy your morning.

Twitter on your desktop in three lines of Python.

It’s nice when things come together. I’ve been sick with envy watching the Lifehacker ‘featured desktop’ posts. All these awesome looking linux desktops, they’re like Audis… sexy as all get-out, but have fun getting them serviced.

Then a couple days ago a Mac OS desktop made the cut, alerting me to GeekTool’s revival. Apparently, GeekTool fell off when Apple went Intel and it’s taken them a while to get things back together. It’s a fairly simple BlitThingsOntoTheDesktop utility that gets the job done.

Well. I wanted the date. My friend Dave wanted to see the date at a glance so badly he resorted to changing his system’s default date format to make the date appear in the menubar. Turns out it has a few icky consequences.

So I throw the date in GeekTool. (Instructions and inspiration here.)

What else? Twitter.

I don’t really like twitter clients much. Tweetie is awesome, but I dunno. It’s always… there. I don’t like many of the ‘not _really_ there’ technologies for getting updates like this either (Growl. grrr.)

So it’s settled. What will it take to get my twitter feed on my desktop?

Turns out, fifteen minutes and about three lines of Python.

import twitter
import os, sys
import textwrap
import string

api = twitter.Api(username = "royalgeoffrey", password = "royalgeoffreyssupersecretpassword")

for s in api.GetFriendsTimeline():
	print textwrap.fill(
		"%s%s" % (string.ljust(s.user.screen_name + ":", 22), s.text),
		width=70,
		initial_indent="",
		subsequent_indent="                      "
		)

	print

download source

That’s it. And really, most of the complexity there is in formatting the output nicely for display at the command line.

Want it? Take it! Substitute your own username and password. You’ll need the python-twitter and simplejson modules. Then set up a GeekTool shell command to run python ~/royalgeoffreycelebritybicycle/twitterfeed.py (assuming you copy the above python source and save it to ~/royalgeoffreycelebritybicycle/twitterfeed.py).

Set it to refresh as often as your comfortable with, and off you go. The results look something like this:

twitterdesktop

I dig it. Beats refreshing the website every time I get bored, or running yet another app that eats up screen real estate.

At any rate. If you’re not versed in dealing with Python modules, and the like.. don’t fret. There’s more coming. Big Plans. Keep watching. I’ll be rolling out some nicer, cleaner, prettied-up stuff based on this idea in the near future.

hello, world

Unfinished, but inspired. Functional, and gets the point across. One of my favorite projects.

celebritybicycle

Here is what it would have looked like when I bought it, had it been taken good care of. Old English pedestrian bicycles put up an incredible fight. None of the bolts are quite English, or metric. Expect to spend more than a day on disassembly. The quality of the steel is incredibly poor. Helpful, since you’ll need to bend the front fork and fenders to fit newer wheels.

Found a seat, some cheap pedals, new cages, old stem, and an affordable bottom bracket with cranks. Replaced fender hardware with brass stuff from Home Depot. Flipped the bars and wrapped the right side with orange tape, plugged with a wine cork from our wedding. Decided I hated the orange, so didn’t bother to tape the other side. Brake is from a Schwinn Varsity; I couldn’t believe it cleared the fender and landed right on the walls without modification.

Not a slouch to ride at all. Twenty-three pounds, and fast as hell.

By the way, this site isn’t about bicycles.