-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFormatCheck.py
41 lines (37 loc) · 1.1 KB
/
FormatCheck.py
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
def format_checker(filename):
FileOpen = open(filename,"r")
ReadFile = FileOpen.readlines()
count = 0
countl = 0
sums = 0
for item in ReadFile:
countl +=1
splititem = item.split()
try:
if len(splititem) == 5:
try:
splititem0= int(splititem[0])
splititem2= int(splititem[2])
splititem3= int(splititem[3])
if splititem[4].isdecimal:
sums+=float(splititem[4])
count+=1
else:
return False
except:
return False
else:
return False
except:
return False
if count == countl:
if sums == 1.0:
return True
else:
return False
else:
return False
FileOpen.close()
#print: True, False .
print(format_checker("sample_1.cs1301"))
print(format_checker("sample_2.cs1301"))