开发者

Google App Engine: How do I save uploaded text file to Blob, then read from it line by line?

开发者 https://www.devze.com 2022-12-19 16:16 出处:网络
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.

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消