I want to scan using Python a folder containing hundreds of .sas and .egp files. The .sas files are not a problem since I can simply read them like that : with open(file_path, 'r', encoding='latin-1') as f: ... But since .egp files do not allow this technique, I use this function to extract the scripts from the archive so that I can then read them: def extract_sas_scripts_from_egp(file_path): scripts = [] extraction_dir = file_path.replace('.egp', '_extracted') # Reset Extraction Folder if os.path.exists(extraction_dir): for file in os.listdir(extraction_dir): os.remove(os.path.join(extraction_dir, file)) else: os.makedirs(extraction_dir) # Extract .sas files from the archive with zipfile.ZipFile(file_path, 'r') as archive: for file_info in archive.infolist(): if file_info.filename.endswith(".sas"): extracted_path = os.path.join(extraction_dir, os.path.basename(file_info.filename)) with archive.open(file_info) as sas_file: content = sas_file.read().decode('latin-1') scripts.append((content, extracted_path)) with open(extracted_path, 'w', encoding='latin-1') as f: f.write(content) return scripts My problem is that the generated "_extracted" folder seems to contain only the first .sas script, leaving out all the others I also need. Questions : Do you know why my script gives this result and how I can make sure to see all my scripts? Do you know any other method to read .egp files? Thank you! Continue reading...