import os list_test os listdir path Users Люция Desktop opensystem tes

 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
import os
list_test = os.listdir(path=u"C:/Users/Люция/Desktop/opensystem/test/")
print(list_test)
def parametrs ( lists_test):
name_file=[]
name=[]
for i in list_test:
a = i
a = a.replace('D' , 'E')
a = a.replace('psi2_G= ' , '')
a = a.replace('.dat' , '')
a = a.replace('psi_G= ' , '')
#print(a)
name.append(float(a))
name_file+=name
return name_file
print(parametrs(list_test))
param = parametrs(list_test)[0]
print(param)
def openfile (onefile):
#one file list_test[o]
count = 0
number = 0.0
f = open("C:/Users/Люция/Desktop/opensystem/test/" + onefile, 'r')
text = f.readlines()
count_lines = len(text)
while (count<count_lines):
line = text[count]
line = line.replace('D', 'E')
stroka = line.split(' ')
a = stroka[4]
number = max(number, float(a))
count = count + 1
f.close()
return number
print(openfile(list_test[0]))
openf = openfile(list_test[0])
print(openf)
#write in file
def writefile (param,openf):
f = open("C:/Users/Люция/Desktop/opensystem/new_f.txt", 'w')
f.write(str(param))
f.write(" ")
f.write(str(openf))
f.writelines(" ")
f.close()
write_end="successful writing"
return write_end
#print(writefile (param,openf))
for count in range(len(list_test)):
maxnumber_in_file = openfile(list_test[count])
name_file = parametrs(list_test)[count]
writefile(name_file , maxnumber_in_file)