get_number_of_chunks

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

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

Parameters
  • file_or_obj (str) – absolute path to a file

  • chunk_size_limit (int or float or 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 or None

Examples:

>>> from pyhelpers.ops import get_number_of_chunks
>>> import os

>>> file_path = "C:\Program Files\Python39\python39.pdb"

>>> os.path.getsize(file_path)
13611008
>>> get_number_of_chunks(file_path, chunk_size_limit=2)
7