h2non / filetype.py

Small, dependency-free, fast Python package to infer binary file types checking the magic numbers signature
https://h2non.github.io/filetype.py
MIT License
650 stars 111 forks source link

The csv file is not recognized. Can it be supported #148

Closed Skypekey closed 1 year ago

Skypekey commented 1 year ago

I want to identify csv files, but csv is not supported, and some other files are also not supported. Can someone briefly describe the idea of code to facilitate adding supported file types

h2non commented 1 year ago

Nope, only binary files, no text format type inference is within the scope of this library.

Although, for that specific case, you can simply check if the file has text content inside that can be read as CSV using csv package. If it fails, it is likely the file is not a CSV, or has the wrong text format.