Bge script - open file in zip

I want a script that can read text files in zip archives. the text object in the game should take values from the text file. I tried to use a script to python from internet to open the zip archive, but the blender threw me an error.

archive = zipfile.ZipFile('', 'r')
#Let us verify the operation..
txtdata ='mail.txt')

Please could anyone write me a script that would work as i describe. Might be another type of archive.

With 7Zip, I created a zip file containing a textfile with a charset and then put it in my D: drive. Testing the exact same script, it worked just fine:

import zipfile;
archive = zipfile.ZipFile('D:\', 'r')
txtdata ='CHR64.txt')

So my guess is you tried to open another kind of file; 7z won’t work, and rar won’t work.

Sadly, I can’t know if something else happened because you didn’t post the error. Mind reading is tough, man.

Please, can you send me blender.file?
I try your script, but same as before. Here is that error

Ah, the \U in \Users is being interpreted as an escape.

Two solutions:

  • Double the backslashes \\
  • Make the path a raw string, ie r"C:\Users\..."