Python library to identify file type based on its file signature
Project description
filext
Python library to identify file type based on its file signature
Installation
pip install filext
Usage
If the category of the file is not certain, you may use whatfile
but is a little slower
from filext import whatfile
file_path = "./tests/files/document.pdf"
# pass file as path str
file_type = whatfile(file_path)
with open(filepath, "rb") as file:
# pass file as bytes
file_type = whatfile(file.read())
If the category of the file is known, you may use the function for that category instead.
from filext import whatdoc
file_path = "./tests/files/document.pdf"
# pass file as path str
file_type = whatdoc(file_path)
with open(filepath, "rb") as file:
# pass file as bytes
file_type = whatdoc(file.read())
Supported File Types
Documents
- DOC
- PPT
- XLS
- DOCX
- PPTX
- XLSX
Images
- BMP
- GIF
- HEIC
- JPG
- PNG
- TIF
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
filext-0.2.2.tar.gz
(5.0 kB
view hashes)
Built Distribution
filext-0.2.2-py3-none-any.whl
(6.5 kB
view hashes)