Created
May 15, 2017 20:24
-
-
Save davidwtbuxton/b0ea7a5b1d3a316d56b5ed1224a11d5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
import csv | |
import hashlib | |
import sys | |
# Calculate an MD5 checksum for every row in the first column of a CSV. | |
# Example: | |
# $ python digests.py < src.csv > dest.csv | |
def main(): | |
reader = csv.reader(sys.stdin) | |
writer = csv.writer(sys.stdout) | |
for row in reader: | |
value = row[0].strip() | |
digest = hashlib.md5() | |
digest.update(value) | |
result = digest.hexdigest() | |
writer.writerow((value, result)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment