【发布时间】:2021-09-06 09:19:56
【问题描述】:
这篇文章might be related to this one。我想用密码或令牌加密 .csv 文件。然后,我想编写一个脚本,使用密码解密文件,将 .csv 文件作为数据框读取,并继续对内容进行数据分析。如何实现这一目标?
例子:
import pandas as pd
import csv
# 1.) Create the .csv file
super_secret_dict = {'super_secret_information':'foobar'}
with open('super_secret_csv.csv','w') as f:
w = csv.DictWriter(f,super_secret_dict.keys())
w.writeheader()
w.writerow(super_secret_dict)
# 2.) Now encrypt the .csv file with a very safe encryption method and generate
# a password/token that can be shared with people that should have access to the
# encrypted .csv file
# ...
# ...
# 3.) Everytime a user wants to read in the .csv file (e.g. using pd.read_csv())
# the script should ask the user to type in the password, then read in
# the .csv file and then continue running the rest of the script
super_secret_df = pd.read_csv('./super_secret_csv.csv')
【问题讨论】:
-
使用 PBKDF2 密钥派生搜索 Aes。
标签: python pandas encryption password-protection password-encryption