Google App Engine: How do I save uploaded text file to Blob, then read from it line by line?
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 anywher开发者_如何学JAVAe. GAE only shows how to deal with images, but I want to read from the stored text file.
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.
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)
精彩评论