import sys
import hashlib
def calculate_md5(fpath: str, chunk_size: int = 1024 * 1024) -> str:
""" Calculates the MD5 checksum of a file located at the path specified by the fpath.
Parameters
----------
fpath : str
File path.
chunk_size : int
Specifies the size of the chunks of the file that are read.
Returns
-------
str
Returns MD5 checksum of a file located at the fpath.
"""
if sys.version_info >= (3, 9):
md5 = hashlib.md5(usedforsecurity=False)
else:
md5 = hashlib.md5()
with open(fpath, "rb") as f:
for chunk in iter(lambda: f.read(chunk_size), b""):
md5.update(chunk)
return md5.hexdigest()
if __name__ == '__main__':
res=calculate_md5(fpath="D:/cnki_1/neurai_project\dataset_load\CJDFTRIPLET/raw11/cjdf500k_9.csv")
print(res)