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

发布于 2024-08-20 17:11:32 字数 171 浏览 2 评论 0原文

我有一个巨大的文件(超过 16,000 行),我想将其保存在数据存储中以供稍后解析。每行包含一个实体的信息。

如何从存储的 Blob 中逐行读取?

我似乎无法在任何地方找到关于 Blob 的好的教程或文档。 GAE 仅展示如何处理图像,但我想读取存储的文本文件。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

上课铃就是安魂曲 2024-08-27 17:11:32

使用 文本 输入进行存储而不是一个斑点。文本的大小没有任何限制,但不可索引或可查询。

因此,如果您想要的只是按顺序逐行访问数据,那么它会完美地工作。

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.

初心 2024-08-27 17:11:32

如果您只需要 blob 中的行,只需执行以下操作:

lines = blob.split("\n")

如果您需要将 blob 视为文件,请执行以下操作:

fh = StringIO.StringIO(blob)

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文