Extract the xz file with python

@ Shared server / environment without pyenv or anaconda

Of course, the Python version should be 2 series.

$ pip install --install-option="--prefix=$HOME/share" backports.lzma
# -*- encoding: utf-8 -*-
try:
    import lzma
except:
    import sys
    sys.path.append('/home/bunzaemon/share/lib64/python2.6/site-packages')
    from backports import lzma

with lzma.open("dat.txt.xz") as f:
    print (f.read().decode())

--The contents are ascii only. --In 2 series, decode () is not necessary. But it works even if there is. --Since it is binary in 3 series, decode () is required.

Recommended Posts

Extract the xz file with python
Extract the targz file using python
Check the existence of the file with python
Let's read the RINEX file with Python ①
[Automation] Extract the table in PDF with Python
Extract zip with Python (Japanese file name support)
Convert the character code of the file with Python3
Extract lines that match the conditions from a text file with python
Download the file in Python
Draw netCDF file with python
Call the API with python3.
Download csv file with python
Extract the table of image files with OneDrive & Python
I tried to touch the CSV file with Python
Extract the band information of raster data with python
Extract template of EML file saved from Thunderbird with python3.7
Extract the maximum value with pandas.
[Automation] Extract Outlook appointments with Python
[Python] Write to csv file with Python
Save the binary file in Python
[Automation with python! ] Part 1: Setting file
Implemented file download with Python + Bottle
Follow the file hierarchy with fts
[Python] Read the csv file and display the figure with matplotlib
Output to csv file with Python
Get the weather with Python requests
Get the weather with Python requests 2
Create an Excel file with Python3
Find the Levenshtein Distance with python
Hit the Etherpad-lite API with Python
Install the Python plugin with Netbeans 8.0.2
Download the file deployed with appcfg.py
I liked the tweet with python. ..
[Beginner] Extract character strings with Python
Master the type with Python [Python 3.9 compatible]
[Automation with python! ] Part 2: File operation
I tried to divide the file into folders with Python
Open the file with the default app
Try to decipher the garbled attachment file name with Python
Python: Extract file information from shared drive with Google Drive API
Read a file in Python with a relative path from the program
The idea of feeding the config file with a python file instead of yaml
Make the Python console covered with UNKO
Creating a simple PowerPoint file with Python
[Python] Set the graph range with matplotlib
Exclusive control with lock file in Python
Read CSV file with python (Download & parse CSV file)
Behind the flyer: Using Docker with Python
[Python] Get the variable name with str
Quickly create an excel file with Python #python
[Python] Round up with just the operator
Display Python 3 in the browser with MAMP
Search the maze with the python A * algorithm
Working with OpenStack using the Python SDK
Read the file line by line in Python
Download files on the web with Python
Read the file line by line in Python
Create Excel file with Python + similarity matrix
Record with Python → Save file (sounddevice + wave)
Learn the design pattern "Singleton" with Python
[Python] Automatically operate the browser with Selenium