Python unzipping stream of bytes?

前端 未结 4 696
时光取名叫无心
时光取名叫无心 2020-11-27 15:34

Here is the situation:

  • I get gzipped xml documents from Amazon S3

    import boto
    from boto.s3.connection import S3Connection
    from boto.s3.key i         
    
    
            
4条回答
  •  無奈伤痛
    2020-11-27 16:23

    You can try PIPE and read contents without downloading file

        import subprocess
        c = subprocess.Popen(['-c','zcat -c '], shell=True, stdout=subprocess.PIPE,         stderr=subprocess.PIPE)
        for row in c.stdout:
          print row
    

    In addition "/dev/fd/" + str(c.stdout.fileno()) will provide you FIFO file name (Named pipe) which can be passed to other program.

提交回复
热议问题