File size: 475 Bytes
c3c2e5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import zipfile

def load_texts_from_zip(zip_path):
    texts = []

    with zipfile.ZipFile(zip_path, 'r') as zip_ref:
        for file_name in zip_ref.namelist():
            if file_name.endswith(".txt"):
                with zip_ref.open(file_name) as f:
                    try:
                        text = f.read().decode("utf-8")
                        texts.append(text)
                    except:
                        continue

    return texts