Created
October 16, 2014 17:28
-
-
Save navicore/e81c3f409eeb5744ced2 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 python | |
import sys | |
import csv | |
# tabbed file tabs.txt: | |
#one two three four | |
# cmd: | |
#cat tabs.txt | ./mask.py 2 CUSTOMER_ | |
POS = int(sys.argv[1]) | |
LABEL = sys.argv[2] | |
def checksum256(start): | |
""" checksum """ | |
return reduce(lambda x, y:x+y, map(ord, start)) % 256 | |
CF = csv.reader(sys.stdin, delimiter='\t') | |
for row in CF: | |
row[POS] = LABEL + str(checksum256(row[1])).zfill(3) | |
print '\t'.join(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment