[英]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. 我有一个巨大的文件(超过16,000行),我想保存在数据存储区中以便以后进行解析。 Each line contains info on an entity. 每行包含有关实体的信息。
How do I read line by line from the stored Blob? 如何从存储的Blob中逐行读取?
I can't seem to find a good tutorial or documentation on a Blob anywhere. 我似乎在任何地方都找不到关于Blob的好的教程或文档。 GAE only shows how to deal with images, but I want to read from the stored text file. GAE仅显示如何处理图像,但我想从存储的文本文件中读取 。
If you simply need the lines from the blob, just do: 如果您只需要Blob中的行,请执行以下操作:
lines = blob.split("\n")
If you need to treat the blob like a file, do: 如果需要将blob视为文件,请执行以下操作:
fh = StringIO.StringIO(blob)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.