rxn.utilities.files.get_file_size_as_string

rxn.utilities.files.get_file_size_as_string(file)[source]

Get the file size as a readable string.

Adapted from https://stackoverflow.com/a/39988702.

Parameters

file (Union[str, PathLike]) – File to get the size for.

Raises

ValueError – if the given path is not a file.

Return type

str

Returns

Readable string for the file size (such as “1000.0 bytes”, “2.3 KB”, or “1.1 MB”).