瀏覽代碼

Check if file exists

Jérôme BUISINE 3 年之前
父節點
當前提交
82ffc9050e
共有 1 個文件被更改,包括 9 次插入7 次删除
  1. 9 7
      find_best_attributes_surrogate.py

+ 9 - 7
find_best_attributes_surrogate.py

@@ -263,14 +263,16 @@ def main():
 
     # check if results are already saved...
     already_saved = False
-    with open(filename_path, 'r') as f:
-        lines = f.readlines()
 
-        for line in lines:
-            output_name = line.split(';')[0]
-            
-            if p_output == output_name:
-                already_saved = True
+    if os.path.exists(filename_path):
+        with open(filename_path, 'r') as f:
+            lines = f.readlines()
+
+            for line in lines:
+                output_name = line.split(';')[0]
+                
+                if p_output == output_name:
+                    already_saved = True
 
     if not already_saved:
         with open(filename_path, 'a') as f: