-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
74 lines (39 loc) · 1.21 KB
/
Copy pathfunctions.py
File metadata and controls
74 lines (39 loc) · 1.21 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
def create_dir(folde_name):
if not os.path.exists(folde_name):
os.makedirs(folde_name)
def remove_dir(folde_name):
os.rmdir(folde_name)
def create_new_file(path):
f = open(path, 'w')
f.write("")
f.close()
def write_to_file(path,data):
with open(path, 'a') as file:
file.write(data + '\n')
file.close()
def clear_file(path):
f= open(path, 'w')
f.close()
def does_file_exists(path):
return os.path.isfile(path)
def read_file(path):
with open(path,'rt') as file:
for line in file:
print(line.replace('\n',''))
def read_lines(path,lines):
with open(path,'rt') as file:
current_line=0
for line in file:
if current_line == lines:
break
current_line =current_line +1
print(line.replace('\n',''))
#calling the functions below:
#remove_dir('wiki')
#create_dir('Wiki2')
#create_new_file('Wiki/test.txt')
#write_to_file("Wiki/test.txt","This is the data we like to store ")
#clear_file("Wiki/test.txt")
#print(does_file_exists('Wiki/test.txt'))
#read_file('Wiki/test.txt')