Files
Brancheneinstufung2/clean_file.py

43 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
import sys
def clean_file(filepath):
print(f"Cleaning {filepath}...")
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
# Replacements map
replacements = {
'\u2013': '-', # En-dash -> Hyphen
'\u20ac': 'EUR', # Euro -> EUR
'\u2192': '->', # Arrow -> ->
'\u201c': '"', # Smart quotes
'\u201d': '"',
'\u2018': "'",
'\u2019': "'"
}
original_len = len(content)
for char, replacement in replacements.items():
content = content.replace(char, replacement)
with open(filepath, 'w', encoding='utf-8') as f:
f.write(content)
print(f"Done. Replaced special characters.")
# Verification check
try:
compile(content, filepath, 'exec')
print("Syntax Check: OK")
except SyntaxError as e:
print(f"Syntax Check: FAILED - {e}")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
clean_file("b2b_marketing_orchestrator.py")