-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseparator_script.py
More file actions
35 lines (28 loc) · 817 Bytes
/
separator_script.py
File metadata and controls
35 lines (28 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sys
import os
def create_file(line):
file_name = "str"
if ("+" in line):
file_name = line + ".scm"
else:
file_name = line[0:8] + ".scm"
if('\n' in file_name) :
file_name = str(file_name).replace('\n','')
return open(file_name, "w")
def main():
file_to_read = open("Sicp_Exercises_all (Till ex 3.70).scm",'r',)
opened_file = None
while True:
line = file_to_read.readline()
if line == "":
break
elif line[0:4] == "----":
continue
elif line[0:2] == "ex" and (line[2] == " " or line[2].isdigit()):
if(opened_file):
opened_file.close()
opened_file = create_file(line)
else :
opened_file.write(line)
file_to_read.close()
main()