Jan Klaas
Jan Klaas

Reputation: 371

Get file size info in Notebook with $magic

Is it possible to get file size info with a magic command in notebook?

I've searched the internet but couldn't find an answer.

Upvotes: 0

Views: 4977

Answers (2)

guidel
guidel

Reputation: 71

My answer is not relative to IPython but you may use the os library in Python, it’s very simple as well. More specifically, you can get the size of a file using

import os
size_bytes = os.stat(<put_file_name_here>).st_size

Note: the result will be in bytes so you can divide by 1 000 000 if you want the result to be in MB.

Upvotes: 2

Jan Klaas
Jan Klaas

Reputation: 371

Answer is !ls -lh which returns info about file size

Upvotes: 1

Related Questions