Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python read gzipped file

# Basic syntax:
import gzip
with gzip.open("your_file.gz", mode="rt") as file:
    file_as_list = file.read().splitlines()
# Where:
#	- gzip.open allows you to open gzipped files like you would open regular
#		files with open
#	- the default mode is rb (read binary), which loads the file contents as
#		binary strings. Use mode="rt" to read the file as text
#	- .read() reads the entire file
#	- .splitlines() splits the file by newline characters to create a list
# Note, see answer to "python open" for more ways to open and parse files
Comment

PREVIOUS NEXT
Code Example
Python :: display selective fields in admin page django 
Python :: import NoSuchKey in boto3 
Python :: count similar values in list python 
Python :: python read entire file as string 
Python :: debugging pytest in vscode 
Python :: how to get all links text from a website python beautifulsoup 
Python :: python pip install from script 
Python :: check if number is power of 2 python 
Python :: python random.choices vs random.sample 
Python :: reload all extensions discord.py 
Python :: how to convert dataframe to list in python 
Python :: how to add images in hml while using flask 
Python :: linear search in python 
Python :: matplotlib plot remove margins 
Python :: pandas sort values reset index 
Python :: django refresh form db 
Python :: plotly add hline dashed 
Python :: get list of all files in folder and subfolders python 
Python :: python iterate columns 
Python :: string module in python 
Python :: cv2 show image 
Python :: size table python 
Python :: python except show error 
Python :: check key pressed pygame 
Python :: get all file names in a folder python 
Python :: built in function in python 
Python :: python date 
Python :: how to do label encoding in multiple column at once 
Python :: pass argument to a py file 
Python :: remove grid in plt 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =