Upload fix.py with huggingface_hub
Browse files
fix.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Programm zur Behebung des UTF-8-Encoding-Problems
|
| 2 |
+
|
| 3 |
+
def fix_encoding(file_path):
|
| 4 |
+
# Öffnen der Datei zum Lesen
|
| 5 |
+
with open(file_path, 'r', encoding='latin1') as file:
|
| 6 |
+
lines = file.readlines()
|
| 7 |
+
|
| 8 |
+
# Überprüfen, ob die Encoding-Zeile bereits vorhanden ist
|
| 9 |
+
if not lines[0].startswith("# -*- coding: utf-8 -*-"):
|
| 10 |
+
# UTF-8-Encoding-Zeile hinzufügen
|
| 11 |
+
lines.insert(0, "# -*- coding: utf-8 -*-\n")
|
| 12 |
+
|
| 13 |
+
# Schreiben der geänderten Datei
|
| 14 |
+
with open(file_path, 'w', encoding='utf-8') as file:
|
| 15 |
+
file.writelines(lines)
|
| 16 |
+
|
| 17 |
+
# Beispiel für die Verwendung
|
| 18 |
+
file_path = "segmentation_infer_html.py" #"annotate-context-caps.py" #"embed_contexts_e5_small.py" #"whisper_softprompt_e5_finetune.py"# '/mnt/raid/spirit/emonet-text/infer_compare_embed_only.py' #emo_acting_prompts.py' # Pfad zur Datei
|
| 19 |
+
fix_encoding(file_path)
|