views:

388

answers:

2

I have a huge file (over 16,000 lines) that I want to save in the datastore for parsing later. Each line contains info on an entity.

How do I read line by line from the stored Blob?

I can't seem to find a good tutorial or documentation on a Blob anywhere. GAE only shows how to deal with images, but I want to read from the stored text file.

+1  A: 

Use the Text type to store it instead of a blob. Text does not have any limits on size, but its not indexable or queryable.

So if all you want is sequential line by line access to the data, it would work perfectly.

Anurag
A: 

If you simply need the lines from the blob, just do:

lines = blob.split("\n")

If you need to treat the blob like a file, do:

fh = StringIO.StringIO(blob)
Nick Johnson