Now Playing Tracks

Simple CSV (or file) upload and parse with GAE

I struggled the past few weeks with an odd bug that I kept declining to fix in my Google App Engine application. I wanted to upload a file and parse some text from that file with Python. I specifically wanted to bypass the blobstore (for reasons that don’t matter here).

Super simple file upload.

All the posts I found said: don’t do this, use blobstore. Instead of just answering the posters question. They would then post a helpful example with blobstore use but only a snippet. I already know I should use blobstore though and my blobstore example works. This was similar but didn’t work and I couldn’t figure out why.. When I requested the file from self.request.get(‘filename’) I simply got back the file name I was uploading and no file.

My problem: def get(self): instead of def post(self); for the function declaration. DOH!

The entire simple example is below so hopefully someone can find the real answer to what they ask instead of “don’t do what you asked, do x”

def post(self):
     self.response.out.write(“——Attempting to upload: %s——\n”%self.request.get(‘filetype’)) #Some other attribute I wanted
stringReader = csv.reader(StringIO.StringIO(self.request.get(‘file’)))
        for row in stringReader: 
         self.response.out.write(‘Row:%s’%row[0])

The form should look like this:

<form method=”POST” enctype=”multipart/form-data” size=”500” action=”/api/save/url”>
<select name=”filetype”>
<option value=”music”>Music</option>
</select>
File:
<input type=”file” name=”file”/>
<input type=”submit” value=”Upload”/><

Oculus Rift - VR!

Tried out the Oculus Rift tonight. I was impressed during the first run by how well it worked. The tuscany demo is impressive. I was actually able to pass the ball between my hands.

Tried out another space ship demo that was a bit disorienting and by my third time in Tuscany I became sick. It became worse when I actually took off the headset. It is now 2 hours later and my hands still feel disconnected from my head. Weird.

It really is neat. I just wish my body would have been okay with it. I’m fairly certain it was from doing non-natural head motions without head tracking in the demos.

Sega Master System Bios Swap

Modded my Sega Master System this evening. Installed a replacement socket-able bios chip and replaced some failing caps in anticipation for conversion to SCART video/audio output.

I still can’t get my European version of Castle of Illusion to boot even after extensive cleaning of the cart and the socket. Phantasy Star 1 loads nicely though and now I can play Japanese card games using my home made adapter!

Oracle Listagg - A 4000 character limit.

11g has this awesome feature called listagg. You can select a field from a subquery and it will roll it up doing a nice concatenate with a custom delimiter. Great! Only it let me down… which is why this post exists. 

Standard ways to perform this task normally involve a for loop building a string over time or using wmsys.wm_concat if I don’t mine having just ‘,’ as a delimiter.

So why did listagg not work? It does everything I want a concatenate function to do but for some reason Oracle decided to limit it to 4000 characters inside PL/SQL. This seems odd to me as most of the newer string operators support the full 32000 characters in PL/SQL or have a clob equivalent.

I poked around dmbs_lob and didn’t see any options so I had to go back to using an ugly/slow loop function/custom concat code. This could seriously cut down our code base if it was implemented to support 32000 characters.

Brewing status and events this weekend.

Chocolate Stout is finished! Cracked the first bottle this weekend and it was very tasty. 

I’ve got half the batch still sitting in a secondary fermenter with 3 pounds of mashed cherries. I plan to leave it there one additional week and do a quick taste test to see if the taste has transferred sufficiently. 

This weekend we’ll be brewing at All Hands Active. If you have any interest in learning how or just hanging out and tasting home brew, feel free to join!

TIL: Oracle vs SQL Server Edition

TIL: In SQL Server - long running selects block read and writes to a table.

In Oracle, they do not block or lock a table. You can specify to lock if you plan to update/insert but that is not default behavior.

You can specify no lock in SQL Server but this isn’t equivalent functionality.

A co-worker encountered this today when an app we pull data from switched from Oracle to SQL Server.

To Tumblr, Love Pixel Union