get_number_of_chunks

pyhelpers.ops.get_number_of_chunks(file_or_obj, chunk_size_limit=50, binary=True)[source]

Get total number of chunks of a data file, given a minimum limit of chunk size.

Parameters:
  • file_or_obj (Any) – absolute path to a file or an object

  • chunk_size_limit (int | float | None) – the minimum limit of file size (in mebibyte i.e. MiB, or megabyte, i.e. MB) above which the function counts how many chunks there could be, defaults to 50;

  • binary (bool) – whether to use binary (i.e. factorized by 1024) representation, defaults to True; if binary=False, use the decimal (or metric) representation (i.e. factorized by 10 ** 3)

Returns:

number of chunks

Return type:

int | None

Examples:

>>> from pyhelpers.ops import get_number_of_chunks
>>> import numpy

>>> example_obj = numpy.zeros((1000, 1000))
>>> get_number_of_chunks(example_obj, chunk_size_limit=5)
2

>>> file_path = "C:\Program Files\Python310\python310.pdb"
>>> get_number_of_chunks(file_path, chunk_size_limit=2)
8