Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

214
Visualizações
Python analog for linux "file" command

I'm looking for file linux command analog made in Python. It should provide information about file type as described in man file. Minimal feature set I'm looking for is to determine if file is raw or text (human-readable) one. Wrapper library will be good suggestion. I know, I can run file as subprocess and grab it's output to determine file type. But my program is supposed to parse thousands of files and I'm afraid of very long execution time in this case.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

you need to check the "magic" byte of the file, and I was about to tell you about:

  • python-magic

when it occured to me that this question should already have been answered on SO, and it has.

N.B.: I'm not listing pymagic as the other post does, as it did not get any update since 0.1 which looks quite old (even the source website is down).

for OSX:

brew install libmagic
pip install python-magic
python
>>> magic.from_file('test.py')
'Python script, ASCII text executable'
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda