Browse Source

added function to write to a file in the gizmo notation

Noah Vogt 4 years ago
parent
commit
ceb02c1474
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/gizmo_funtions.py

+ 8 - 1
src/gizmo_funtions.py

@@ -9,7 +9,7 @@ def return_part(input_list, split_index):
 
 
 # function to replace a substring of a 'part' from each line of the 'gizmo notation'
 # function to replace a substring of a 'part' from each line of the 'gizmo notation'
 def replace_substring_of_list_part(input_list, split_index, pattern, replace_str):
 def replace_substring_of_list_part(input_list, split_index, pattern, replace_str):
-    
+
     # create a temporary list with the selected 'part'
     # create a temporary list with the selected 'part'
     working_list = []
     working_list = []
     for sub in input_list:
     for sub in input_list:
@@ -49,6 +49,13 @@ def gizmo_stdout(input_list):
     for item in input_list:
     for item in input_list:
         print(item)
         print(item)
 
 
+# function to write to a (new) file in the 'gizmo notation'
+def gizmo_write2file(input_list, path_to_file):
+    with open(path_to_file, "w+") as file_writer:
+        for item in input_list:
+            file_writer.write(item+"\n")
+        file_writer.close()
+
 # function to read from standard input and return it a list of each line
 # function to read from standard input and return it a list of each line
 def stdin():
 def stdin():
     stdin_list = []
     stdin_list = []