简体   繁体   English

Google App Engine:如何将上传的文本文件保存到Blob,然后逐行读取?

[英]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仅显示如何处理图像,但我想存储的文本文件中读取

Use the Text type to store it instead of a blob. 使用Text 类型存储它而不是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: 如果您只需要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.

相关问题 如何在Google App Engine中将文本字符串作为Blob类型保存到数据存储中? - How do I save a text string into datastore as blob type in Google App Engine? 如何逐行读取文本文件并从文件内容中返回两个字符串和一个列表? - How do I read a text file line by line and return two strings and a list from the contents of the file? 如何逐行读取文本文件并将值保存到python中的变量中 - How to read text file line by line and save values into variables in python 如何读取文本文件中的特定行? - How do I read a specific line on a text file? 逐行读取文本文件,并从一行中计算特定单词的特定值,并将该行保存在该行上方 - Read text file line by line and Count specific word for particular values from a line and save the line above that 如何在文本文件中搜索行的内容,替换行并另存为新文件? - How do I search for contents of a line in a text file, replace the line, and save as a new file? 如何从每一行文本中读取特定字符并将其写到另一个文件中? - How do I read in specific characters from each line of text and write it out to another file? 如何从文件中读取特定行的文本并将其用作函数的参数 - How do i read a specific line of text from a file and use it as a parameter for a function 我如何从 python 中的特定行读取文本文件? - How i can Read text file from a specific line in python? 如何从一个文件中随机读取一行? - How do I read a random line from one file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM