from zipfile import ZipFile 

Extract zip file

    with ZipFile("myzipfile.zip", 'r') as zip_object: 

    #zip_object.extract("text1.txt", path="C:\\m,y_folder\\temp")     #Extracting a specific file in the zip to a specific location

        zip_object.extractall()            #If you don' provide a path is will extract to the current folder

        zip_object.close()
Create zip file
    with ZipFile(LIGHTING_IMPORT_FILE_NAME, 'w') as zip_object:
        # Adding files that need to be zipped
        zip_object.write("text1.txt")
        zip_object.write("spreadsheet1.csv")

    # Check to see if the zip file is created
    if os.path.exists(LIGHTING_IMPORT_FILE_NAME):
        print("New lighting file create with changes: " + LIGHTING_IMPORT_FILE_NAME)
    else:
        print("An error occured, couldn't create new zip file")
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *