Browse Source

Check if file exists

Jérôme BUISINE 1 year ago
parent
commit
82ffc9050e
1 changed files with 9 additions and 7 deletions
  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: