Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writestr method creates empty file #11

Closed
helelily opened this issue Aug 3, 2020 · 3 comments
Closed

writestr method creates empty file #11

helelily opened this issue Aug 3, 2020 · 3 comments

Comments

@helelily
Copy link

helelily commented Aug 3, 2020

import pandas
import pyzipper

data = [[1,2],[3,4], [5,6]]
data = pandas.DataFrame(data)
data.columns = ['one','two']

pw = 'testing'

with pyzipper.AESZipFile('ziptest.zip','w',
                         encryption=pyzipper.WZ_AES) as zf:
    zf.setpassword(pw.encode('utf-8'))
    zf.writestr('test.csv',data.to_csv())

This snippet successfully creates a protected archive but the file it writes to is empty, seems like something is happening in the writestr method?

For context I'm on a mac and python is version 3.7.4

@danifus
Copy link
Owner

danifus commented Aug 3, 2020

Hi,

I've confirmed that writestr is working for me for both str and bytes content. Can you confirm that data.to_csv() is returning content to be written?

Thanks,
Dan

@helelily
Copy link
Author

helelily commented Aug 5, 2020

Hi, I'm realizing now it does work programmatically, the main thing was that the extraction utility I was using on my mac was not compatible. I had to find a different utility to open it as an end user - I guess that is expected behavior?

@danifus
Copy link
Owner

danifus commented Aug 5, 2020

Yeah, that's expected behaviour. AES protected zips aren't supported by all zip utilities (most that come with the OS don't support it).

Glad to hear you got it working :)

@danifus danifus closed this as completed Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants