Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# Ignore all files inside notebooks directory but track the .gitkeep file
notebooks/*
!notebooks/.gitkeep

# IPython
profile_default/
ipython_config.py
Expand Down
34 changes: 34 additions & 0 deletions calculate_sha256.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment, I believe shasum usually comes with with most OSes.

Anyways, there are two files of calculate_sh256.py.

I think it's ok to leave it in here as a utility function in the utils folder and delete this file instead.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import hashlib
from pathlib import Path
import sys

def calculate_sha256(filepath: Path):
"""Calculates the SHA256 hash for a given file."""
if not filepath.exists():
print(f"Error: File not found at {filepath}")
return

sha256_hash = hashlib.sha256()
try:
with open(filepath, "rb") as f:
# Read and update hash string value in chunks of 4K
for byte_block in iter(lambda: f.read(4096), b""):
sha256_hash.update(byte_block)

calculated_hash = sha256_hash.hexdigest()
print("-" * 50)
print(f"File Path: {filepath}")
print(f"SHA256 Checksum: {calculated_hash}")
print("-" * 50)

except Exception as e:
print(f"An error occurred while reading the file: {e}")

if __name__ == "__main__":
if len(sys.argv) < 2:
target_path = Path("data") / "raw" / "2024" / "1.0" / "2024_EAVS_for_Public_Release_V1_xlsx.xlsx"
else:
# Allow passing the path as a command-line argument
target_path = Path(sys.argv[1])

calculate_sha256(target_path)
Loading