我正在處理一個數據集,該數據集具有我想用作唯一標識的用戶社會安全號(沒有破折號),但想要散列(md5)字符串以便保護用戶的身份。這是該數據集的樣本:Python中的哈希字符串
id | date | sale_id
543875600 2014-03-22 a4395
想輸出看起來像這樣或類似:
id | date | sale_id
762be25b5c6eb20dd6c791840c01aa33 2014-03-22 a4395
我想用Python作爲我目前使用python與解決數據彙總許多文件的目錄內,因此這將是額外的代碼,我將包括以下代碼:
import glob
files = glob.glob('*.csv')
output="combined.csv"
with open(output, 'w') as result:
for thefile in files:
f = [open(thefile).read()]
for line in f:
result.write(line)
message = 'file created'
print (message)
哈希代碼:https://docs.python.org/2/library/hashlib.html – 2015-03-13 11:07:31
也許最好是使用一些散列函數來保護用戶的身份。 – Zlopez 2015-03-13 11:07:50
你的問題是什麼? – mkrieger1 2015-03-13 13:45:39