Файлы .sas не являются проблемой, поскольку я могу их просто прочитать вот так:
Код: Выделить всё
with open(file_path, 'r', encoding='latin-1') as f:
...
< pre class="lang-py Prettyprint-override">
Код: Выделить всё
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
Вопросы:
- Знаете ли вы, почему мой сценарий дает такой результат и как я могу убедиться, что я вижу все свои сценарии?
- Знаете ли вы какой-нибудь другой способ чтения? Файлы .egp?
Подробнее здесь: https://stackoverflow.com/questions/792 ... rise-guide
Мобильная версия