0

I have been using python for only about two months so I am still quite new to coding.

Recently, in work, I wrote a code which opens an existing CSV file, performs a few operations and spits out a new CSV file. That bit I am happy with.

But what I want to know is what can I do in terms of securing the document and still running the code to open it? For example, I want to password protect this CSV file but want to prompt the user for the password which will be the only way to open/read the file.

Can anyone point me in the right direction please?

1 Answers1

0

The CSV file is simply a formatted text (.txt) file. So to protect the file there are a few approaches.

  1. Save CSV file then change permissions on it using OS commands - Password Protecting Excel file using Python
  2. zip the csv file with password. Unfortunately, "The builtin zipfile module does not support writing password-encrypted files (only reading). Either you could use pyminizip. Refer to Create password protected zip file Python
frankr6591
  • 1,211
  • 1
  • 8
  • 14