123456789101112131415161718192021222324 |
- import hashlib
- import io
- from pathlib import Path
- def get_hash(filename):
- with open(filename, "r", encoding="latin-1", buffering=0) as frh:
- with open(filename + ".sha", "w", encoding="latin-1") as fwh:
- chunk = io.StringIO()
- for i, line in enumerate(frh.readlines()):
- chunk.write(line)
- if i % 1000 == 0:
- m = hashlib.sha256(chunk.getvalue().encode())
- chunk.truncate(0)
- fwh.write(m.hexdigest() + "\n")
- def main():
- for f in Path("datev/data").glob("*.csv"):
- get_hash(str(f))
- if __name__ == "__main__":
- main()
|