Spaces:
Runtime error
Runtime error
Download preprocessing/data_loader.py from kamalabharathi4deffo/mcq: direct link, hf CLI and curl.
- Browser
- Download file 475 Bytes
-
https://huggingface.co/spaces/kamalabharathi4deffo/mcq/resolve/main/preprocessing/data_loader.py
- Command line
-
hf download hf://spaces/kamalabharathi4deffo/mcq/preprocessing/data_loader.py
-
curl -L -o data_loader.py https://huggingface.co/spaces/kamalabharathi4deffo/mcq/resolve/main/preprocessing/data_loader.py
475 Bytes
| 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 |