import apache_beam as beam
from apache_beam import coders, io, transforms
raw_logs = p | io.Read('ReadLogsFromGCS', beam.io.TextFileSource(
    'gs://my-bucket/logs-*.gz', coder=coders.BytesCoder())) | transforms.Map(
    lambda x: x) | io.Write('WriteToLocalhost', io.textio.WriteToText(
    '/tmp/flattened-logs', file_name_suffix='.json'))
p.run()
Opening a gzip file in python Apache Beam