<small id='pg9An'></small><noframes id='pg9An'>

    <tfoot id='pg9An'></tfoot>
  • <legend id='pg9An'><style id='pg9An'><dir id='pg9An'><q id='pg9An'></q></dir></style></legend>

          <bdo id='pg9An'></bdo><ul id='pg9An'></ul>
        <i id='pg9An'><tr id='pg9An'><dt id='pg9An'><q id='pg9An'><span id='pg9An'><b id='pg9An'><form id='pg9An'><ins id='pg9An'></ins><ul id='pg9An'></ul><sub id='pg9An'></sub></form><legend id='pg9An'></legend><bdo id='pg9An'><pre id='pg9An'><center id='pg9An'></center></pre></bdo></b><th id='pg9An'></th></span></q></dt></tr></i><div id='pg9An'><tfoot id='pg9An'></tfoot><dl id='pg9An'><fieldset id='pg9An'></fieldset></dl></div>
      1. 将CSV写入Google云存储

        Write csv to google cloud storage(将CSV写入Google云存储)

        • <small id='WrsE9'></small><noframes id='WrsE9'>

          <legend id='WrsE9'><style id='WrsE9'><dir id='WrsE9'><q id='WrsE9'></q></dir></style></legend>

          1. <tfoot id='WrsE9'></tfoot>
          2. <i id='WrsE9'><tr id='WrsE9'><dt id='WrsE9'><q id='WrsE9'><span id='WrsE9'><b id='WrsE9'><form id='WrsE9'><ins id='WrsE9'></ins><ul id='WrsE9'></ul><sub id='WrsE9'></sub></form><legend id='WrsE9'></legend><bdo id='WrsE9'><pre id='WrsE9'><center id='WrsE9'></center></pre></bdo></b><th id='WrsE9'></th></span></q></dt></tr></i><div id='WrsE9'><tfoot id='WrsE9'></tfoot><dl id='WrsE9'><fieldset id='WrsE9'></fieldset></dl></div>
              <tbody id='WrsE9'></tbody>
              • <bdo id='WrsE9'></bdo><ul id='WrsE9'></ul>
                  本文介绍了将CSV写入Google云存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想了解如何将多行CSV文件写入Google云存储。我只是没有理解documentation

                  靠近此处: Unable to read csv file uploaded on google cloud storage bucket

                  示例:

                  from google.cloud import storage
                  from oauth2client.client import GoogleCredentials
                  import os
                  
                  os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = "<pathtomycredentials>"
                  
                  a=[1,2,3]
                  
                  b=['a','b','c']
                  
                  storage_client = storage.Client()
                  bucket = storage_client.get_bucket("<mybucketname>")
                  
                  blob=bucket.blob("Hummingbirds/trainingdata.csv")
                  
                  for eachrow in range(3):
                      blob.upload_from_string(str(a[eachrow]) + "," + str(b[eachrow]))
                  

                  这会让您在Google云存储上获得一行

                  3,c
                  

                  显然,它每次都打开一个新文件并写入该行。

                  好的,添加一个新行delim怎么样?

                  for eachrow in range(3):
                      blob.upload_from_string(str(a[eachrow]) + "," + str(b[eachrow]) + "
                  ")
                  

                  这将添加换行符,但再次从头开始写入。

                  谁能说明一下这种方法是什么?我可以将所有行合并到一个字符串中,也可以编写一个临时文件,但这似乎非常难看。

                  可能是以文件形式打开?

                  推荐答案

                  blob.upload_from_string(data)方法创建一个新对象,其内容正好是字符串data的内容。它覆盖现有对象,而不是追加。

                  最简单的解决方案是将整个CSV写入临时文件,然后使用blob.upload_from_filename(filename)函数将该文件上载到GCS。

                  这篇关于将CSV写入Google云存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  GUI Freezes while downloading PyQt5 and Pytube(GUI在下载PyQt5和Pytube时冻结)
                  How to solve memory issues while multiprocessing using Pool.map()?(如何解决使用Pool.map()进行多处理时的内存问题?)
                  Python - How to use FastAPI and uvicorn.run without blocking the thread?(Python-如何使用FastAPI和uvicorn.run而不阻塞线程?)
                  How to increment a shared counter from multiple processes?(如何从多个进程递增共享计数器?)
                  Using pika, how to connect to rabbitmq running in docker, started with docker-compose with external network?(使用pika,如何连接运行在docker中的rabbitmq,从docker开始-与外部网络连接?)
                  How to use .rolling() on each row of a Pandas dataframe?(如何对 pandas 数据帧的每一行使用.roll()?)

                      <tbody id='ggs8H'></tbody>
                      <bdo id='ggs8H'></bdo><ul id='ggs8H'></ul>
                    • <i id='ggs8H'><tr id='ggs8H'><dt id='ggs8H'><q id='ggs8H'><span id='ggs8H'><b id='ggs8H'><form id='ggs8H'><ins id='ggs8H'></ins><ul id='ggs8H'></ul><sub id='ggs8H'></sub></form><legend id='ggs8H'></legend><bdo id='ggs8H'><pre id='ggs8H'><center id='ggs8H'></center></pre></bdo></b><th id='ggs8H'></th></span></q></dt></tr></i><div id='ggs8H'><tfoot id='ggs8H'></tfoot><dl id='ggs8H'><fieldset id='ggs8H'></fieldset></dl></div>

                            <small id='ggs8H'></small><noframes id='ggs8H'>

                            <tfoot id='ggs8H'></tfoot>

                          1. <legend id='ggs8H'><style id='ggs8H'><dir id='ggs8H'><q id='ggs8H'></q></dir></style></legend>