This post might be related to this one. I would like to encrypt a .csv file with a password or token. I would then like to write a script that decrypts the file using the password, reads in the .csv file as a data frame, and continues doing data analysis with the content. How would one achieve this?
Example:
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')