Datasets:
Download scripts/generate_checksums.py from paeslemesa/matchgeodem: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/datasets/paeslemesa/matchgeodem/resolve/main/scripts/generate_checksums.py
- Command line
-
hf download hf://datasets/paeslemesa/matchgeodem/scripts/generate_checksums.py
-
curl -L -o generate_checksums.py https://huggingface.co/datasets/paeslemesa/matchgeodem/resolve/main/scripts/generate_checksums.py
1.44 kB
| #!/usr/bin/env python3 | |
| """ | |
| generate_checksums.py | |
| ===================== | |
| Generates SHA-256 checksums for all data files in the MatchGeo dataset. | |
| Usage: | |
| python generate_checksums.py --data-root /path/to/MatchGeo-DEM-v1 --output checksums.sha256 | |
| """ | |
| import hashlib | |
| import argparse | |
| from pathlib import Path | |
| def sha256_file(filepath): | |
| """Return SHA-256 hex digest of a file.""" | |
| h = hashlib.sha256() | |
| with open(filepath, "rb") as f: | |
| for chunk in iter(lambda: f.read(8192 * 1024), b""): | |
| h.update(chunk) | |
| return h.hexdigest() | |
| def main(): | |
| data_root = "/home/sabrina/Documents/Tese/05_Dataset/MatchGeo-DEM-v1" | |
| output = "checksums.sha256" | |
| include = [".tif", ".json", ".geojson", ".csv", ".qmd", ".cff", ".md"] | |
| data_root = Path(data_root) | |
| output_path = Path(output) | |
| print("=" * 60) | |
| print("MatchGeo-DEM Checksum Generator") | |
| print("=" * 60) | |
| entries = [] | |
| for ext in include: | |
| for filepath in sorted(data_root.rglob(f"*{ext}")): | |
| if ".git" in str(filepath): | |
| continue | |
| rel = filepath.relative_to(data_root) | |
| digest = sha256_file(filepath) | |
| entries.append(f"{digest} {rel}") | |
| print(f" {rel}") | |
| output_path.write_text("\n".join(entries) + "\n", encoding="utf-8") | |
| print(f"\n✅ {len(entries)} files hashed → {output_path}") | |
| print("=" * 60) | |
| if __name__ == "__main__": | |
| main() | |