Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Password protected zip file wont output correctly?

I am using Python to create a list of groups. It only makes sense to me that, using the code, I have for creating the password protected zip, I can create the input in my code as long as it is created before listing the input. As such, I have created a txt file which then needs to be placed in a password protected zip. With the code I am using below, I get this error message when I try to run it: (OSError: error in opening /Users/name/Desktop/Groups.txt for reading). I’m simply not very experienced in this regard and wouldn’t know how to solve this issue (+ I am extremely desperate right now). This is the code I have so far, but it does not work:

#creates .txt file to put in zip folder
with open("Groups.txt", 'w') as file:
    file.write("Each row is a group:" + '\n')
    for row in final_group:
        s = ", ".join(map(str, row))
        file.write(s+'\n')

# creates password protected zip
inpt = "/Users/name/Desktop/Groups.txt"
pre = None
oupt = "/Users/name/Desktop/Groups.zip"
password = "password"
com_lvl = 5
pyminizip.compress(inpt, None, oupt, password, com_lvl)

Could someone help me out here?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The input file might be in a different directory, because of which there’s an error. You can either

  1. Set inpt = "Groups.txt"
  2. Set with open("/Users/name/Desktop/Groups.txt", 'w') as file:
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading